-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Streams: Breaking Change in Behavior after node 17.1 #41700
Comments
@nodejs/streams |
The actual issue is the "Attempting Append Operation" being failed due to an error that is not traversing to the top-level code. The reason for this error is Is it the right behavior or not? If not, we can think about a fix. CC: @ronag Error is not being thrown because we are stopping the error propagation.
|
@MrJithil, am I correct that your proposed solution would still leaving the breaking change in place. It would simply surface an error where no error occurred previously |
BTW, before someone proposes that I could simply create a new write stream over the output file, opened in append mode, consider the (real world) use case where I have a pipeline that includes zip and encryption streams in the pipeline prior to the final write stream, and I want to stop the finished/end from propagating to the zip, encryption and write streams. |
In my opinion this is not a breaking change because you are overriding a core behavior of streams, Note that you also have some subtle bugs in your code: in the event that one of the sources errors, your destination stream will be destroyed, making the second block not work. At a very high level you should not be using @ronag do you think there is a way to handle this case anyway? |
That example does not look like good code practice. I think we landed const os = fs.createWriteStream(__filename + ".copy")
await pipeline(fs.createReadStream(__filename), os, { end: false })
await pipeline(fs.createReadStream(__filename), os) |
The example provided was designed to be a minimal testcase, and as such does include adequate error handling or other good coding practices. I have always assumed that this makes it easier to understand the problem I do believe that this is a breaking change. Obviously, it up to you whether you choose to fix it or not. However, if you believe the new behavior is correct then I would have expected you to release note it. @ronag
In this example I would need to stop the 'end' on cipherStream, compressor and os. I am not sure whether this is possible given the example above |
const dst = compose(cipherStream, compressor, os)
await pipeline(fs.createReadStream(__filename), dst, { end: false })
await pipeline(fs.createReadStream(__filename), dst) |
I'm not sure what the breaking change here is. Don't quite understand the original example. |
The original example is a simple test case that shows that, in 17.1, I could include a subclass of the PassThrough stream which overrides pipe() to prevent 'end' events from propagating, in a pipeline operation and this would prevent the 'end' event from propagating to the components to the right of the PassThrough when the reader reached the end of the file. I could then start a second pipeline operation that would feed additional data to the streams that occurred to the right of the PassThrough in the original pipeline. In 17.2 this stops working. Your implementation of |
But I hadn't seen compose() prior to this. I think this will solve my issue. I will test and get back to you. Is there a way of telling which version of node has the |
@ronag Using BTW in another thread you alluded to async versions of _write() etc, but I still don't see any documentation. Does this mean that the promises library contains a new version of any class that currently relies on one or more functions that take a callback, e.g. Writeable, Transform? What about PassThrough ? Do you have a simple example of an async Writeable ? |
Version
17.3.1
Platform
Microsoft Windows NT 10.0.22000.0 x64
Subsystem
Streams
What steps will reproduce the bug?
Run the following simple testcase
In node 17.1.0 the "finished" promise resolves and the second pipeline is executes and completes and the output file is twice the size of the input file
In node 17.4.0 node the finished promise resolves and the append operation is attempted. However, it appears that despite no error being thrown, the second copy never completes.
This may be related to #34805 (comment)
How often does it reproduce? Is there a required condition?
See the above testcase
What is the expected behavior?
IMHO the 17.1.0 behavior is correct ?
What do you see instead?
See the testcase
Additional information
No response
The text was updated successfully, but these errors were encountered: