forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zlib: allow writes after readable 'end' to finish
Call the callback for writes that occur after the stream is closed. This also requires changes to the code to not call `.destroy()` on the stream in `.on('end')`, and to ignore chunks written afterwards. Previously, these writes would just queue up silently, as their `_write()` callback would never have been called. Fixes: nodejs#30976
- Loading branch information
Showing
2 changed files
with
21 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const zlib = require('zlib'); | ||
|
||
// Regression test for https://github.com/nodejs/node/issues/30976 | ||
// Writes to a stream should finish even after the readable side has been ended. | ||
|
||
const data = zlib.deflateRawSync('Welcome'); | ||
|
||
const inflate = zlib.createInflateRaw(); | ||
|
||
inflate.resume(); | ||
inflate.write(data, common.mustCall()); | ||
inflate.write(Buffer.from([0x00]), common.mustCall()); | ||
inflate.write(Buffer.from([0x00]), common.mustCall()); | ||
inflate.flush(common.mustCall()); |