-
-
Notifications
You must be signed in to change notification settings - Fork 37.1k
stream.pipeline destroys writable stream when error is occurred #26311
Copy link
Copy link
Closed
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.streamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.
Description
Activity
Metadata
Metadata
Assignees
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.streamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.
Version:
v11.10.0
Platform:
Mac OS Darwin 16.7.0
Subsystem:
stream, http
stream.pipeline is helpful to handle error and interoperable to Promise.
However, I found a behavior that is not suitable my usecase.
I am creating a web server with stream.pipeline.
If my readable stream emits an error like "file not found", I would like to send
errorresponse to my clients.code example is as follows.
I have investigated nodejs core, stream.pipeline destroys writable stream when error is occurred.
https://github.com/nodejs/node/blob/master/lib/internal/streams/pipeline.js#L42
so the above code cannot send error response.
Question
Is this an expected behaviour?
In my understandings, writable stream should be closed anyway, but in this case, we would like to close writable stream manually.
In this situation, we need to create custom writable stream?
I could send a PR to pass an option like
{ destroyOnError: false }to avoid destory automatically.