| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b1b7f67 commit 7cad756
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -264,7 +264,7 @@ function ZlibBase(opts, mode, handle, { flush, finishFlush, fullFlush }) { | |||
| 264 | 264 | this._defaultFlushFlag = flush; | |
| 265 | 265 | this._finishFlushFlag = finishFlush; | |
| 266 | 266 | this._defaultFullFlushFlag = fullFlush; | |
| 267 | - this.once('end', this.close); | ||
| 267 | + this.once('end', _close.bind(null, this)); | ||
| 268 | 268 | this._info = opts && opts.info; | |
| 269 | 269 | } | |
| 270 | 270 | Object.setPrototypeOf(ZlibBase.prototype, Transform.prototype); | |
@@ -476,7 +476,7 @@ function processChunkSync(self, chunk, flushFlag) { | |||
| 476 | 476 | ||
| 477 | 477 | function processChunk(self, chunk, flushFlag, cb) { | |
| 478 | 478 | const handle = self._handle; | |
| 479 | - assert(handle, 'zlib binding closed'); | ||
| 479 | + if (!handle) return process.nextTick(cb); | ||
| 480 | 480 | ||
| 481 | 481 | handle.buffer = chunk; | |
| 482 | 482 | handle.cb = cb; | |
@@ -502,13 +502,9 @@ function processCallback() { | |||
| 502 | 502 | const self = this[owner_symbol]; | |
| 503 | 503 | const state = self._writeState; | |
| 504 | 504 | ||
| 505 | - if (self._hadError) { | ||
| 506 | - this.buffer = null; | ||
| 507 | - return; | ||
| 508 | - } | ||
| 509 | - | ||
| 510 | - if (self.destroyed) { | ||
| 505 | + if (self._hadError || self.destroyed) { | ||
| 511 | 506 | this.buffer = null; | |
| 507 | + this.cb(); | ||
| 512 | 508 | return; | |
| 513 | 509 | } | |
| 514 | 510 | ||
@@ -528,6 +524,7 @@ function processCallback() { | |||
| 528 | 524 | } | |
| 529 | 525 | ||
| 530 | 526 | if (self.destroyed) { | |
| 527 | + this.cb(); | ||
| 531 | 528 | return; | |
| 532 | 529 | } | |
| 533 | 530 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,16 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const zlib = require('zlib'); | ||
| 4 | + | ||
| 5 | + // Regression test for https://github.com/nodejs/node/issues/30976 | ||
| 6 | + // Writes to a stream should finish even after the readable side has been ended. | ||
| 7 | + | ||
| 8 | + const data = zlib.deflateRawSync('Welcome'); | ||
| 9 | + | ||
| 10 | + const inflate = zlib.createInflateRaw(); | ||
| 11 | + | ||
| 12 | + inflate.resume(); | ||
| 13 | + inflate.write(data, common.mustCall()); | ||
| 14 | + inflate.write(Buffer.from([0x00]), common.mustCall()); | ||
| 15 | + inflate.write(Buffer.from([0x00]), common.mustCall()); | ||
| 16 | + inflate.flush(common.mustCall()); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments