-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(NODE-4788)!: use implementer Writable methods for GridFSBucketWriteStream #3808
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0bde921
to
e6aebb4
Compare
e6aebb4
to
bb2fcfc
Compare
nbbeeken
commented
Aug 11, 2023
durran
requested changes
Aug 14, 2023
durran
approved these changes
Aug 15, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
What is changing?
Is there new documentation needed for these changes?
What is the motivation for this change?
Node.js Streams are supposed to be implemented with the _X methods, the write & end functions are maintained by Node.js, the _ methods define the implementation of a stream.
Release Highlight
Corrected
GridFSBucketWriteStream
'sWritable
method overrides and event emissionOur implementation of a writeable stream for GridFSBucketWriteStream mistakenly overrode the
write()
andend()
methods, as well as, manually emitted'close'
,'drain'
,'finish'
events. Per Node.js documentation, these methods and events are intended for the Node.js stream implementation to provide, and an author of a stream implementation is supposed to override_write
,_final
, and allow Node.js to manage event emitting.Since the API is still a
Writable
stream most usages will continue to work with no changes, the.write()
and.end()
methods are still available and take the same arguments. The breaking change relates to the improper manually emitted event listeners that are now handled by Node.js. The'finish'
and'drain'
events will no longer receive theGridFSFile
document as an argument (this is the document inserted to the bucket's files collection after all chunks have been inserted). Instead, it will be available on the stream itself as a property:gridFSFile
.Since the class no longer emits its own events: static constants
GridFSBucketWriteStream.ERROR
,GridFSBucketWriteStream.FINISH
,GridFSBucketWriteStream.CLOSE
have been removed to avoid confusion about the source of the events and the arguments their listeners accept.Fix manually emitted events from
GridFSBucketReadStream
The
GridFSBucketReadStream
internals have also been corrected to no longer emit events that are handled by Node's stream logic. Since the class no longer emits its own events: static constantsGridFSBucketReadStream.ERROR
,GridFSBucketReadStream.DATA
,GridFSBucketReadStream.CLOSE
, andGridFSBucketReadStream.END
have been removed to avoid confusion about the source of the events and the arguments their listeners accept.Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript