-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stream: don't emit finish after close
Writable stream could emit 'finish' after 'close'. PR-URL: #32933 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
- Loading branch information
1 parent
fad188f
commit 3c07b17
Showing
3 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const { Writable } = require('stream'); | ||
|
||
{ | ||
const w = new Writable({ | ||
write: common.mustCall((chunk, encoding, cb) => { | ||
w.on('close', common.mustCall(() => { | ||
cb(); | ||
})); | ||
}) | ||
}); | ||
|
||
w.on('finish', common.mustNotCall()); | ||
w.end('asd'); | ||
w.destroy(); | ||
} | ||
|
||
{ | ||
const w = new Writable({ | ||
write: common.mustCall((chunk, encoding, cb) => { | ||
w.on('close', common.mustCall(() => { | ||
cb(); | ||
w.end(); | ||
})); | ||
}) | ||
}); | ||
|
||
w.on('finish', common.mustNotCall()); | ||
w.write('asd'); | ||
w.destroy(); | ||
} |
3c07b17
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.
@lpinca @mcollina @nodejs/streams
This fails
ws
on v14 since it is missing #31806 which fixes a bug innet.Socket
where the socket is destroyed before'finish'
has been emitted.With this change and without #31806,
'finish'
will never be emitted even though it should. I guess being emitted with the wrong timing is better than not at all.I think we can fix
net.Socket
in way that is landable on v14.