-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
stream: eos on closed #28748
stream: eos on closed #28748
Conversation
3c57be4
to
c9d1e19
Compare
/ping @nodejs/streams |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind to add the equivalent test for Readable as well?
c9d1e19
to
3816f11
Compare
@mcollina updated |
aefe068
to
1588c78
Compare
40b4c0b
to
39ca23a
Compare
@benjamingr ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@nodejs/tsc this needs another review. |
@mcollina: Should this maybe result in a |
@mcollina: done |
@Trott: Updated PR description to describe the included changes from the other PR (which is now closed). |
This needs another CITGM (once Travis is ok) given the recent changes. |
return callback.call(stream, err); | ||
callback.call(stream, new ERR_STREAM_PREMATURE_CLOSE()); | ||
} else if (writable && !writableFinished) { | ||
callback.call(stream, new ERR_STREAM_PREMATURE_CLOSE()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an added test for this change. We should always be emitting premature close
unless we've seen finish
or end
events. I don't think this actually changes anything in practice.
This will need a rebase, otherwise it looks good to land. |
db6eb4f
to
9b5a84e
Compare
rebased |
Landed in b03845b |
Make stream.finished callback invoked if stream is already closed/destroyed. PR-URL: #28748 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
A little late to the party here, but this includes a big change in behaviour for streams. Since the finished flag is used instead of the ended flag, this PR changes the behaiviour of eos to the following: const stream = require('stream')
const ws = new stream.Writable({
write (data, enc, cb) {
process.nextTick(cb, null)
}
})
finished(ws, function (err) {
console.log('This used to *not* error:', err)
})
ws.write('data')
ws.end()
ws.emit('close') // modules tend to emit close on resource close but in a non error state I was just bitten by this in a debugging session, so unsure if that was an intentional change? Streams are hard. |
stream.finished
should be invoked if stream is already closed/destroyed. Currently there is a potential deadlock depending on whenstream.finished
is called.For writable premature close is close before finish, i.e. it should look for
finished
instead ofended
.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes