| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d131877 commit 31bbae7
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -275,7 +275,7 @@ function ZlibBase(opts, mode, handle, { flush, finishFlush, fullFlush }) { | |||
| 275 | 275 | this._defaultFlushFlag = flush; | |
| 276 | 276 | this._finishFlushFlag = finishFlush; | |
| 277 | 277 | this._defaultFullFlushFlag = fullFlush; | |
| 278 | - this.once('end', this.close); | ||
| 278 | + this.once('end', _close.bind(null, this)); | ||
| 279 | 279 | this._info = opts && opts.info; | |
| 280 | 280 | } | |
| 281 | 281 | ObjectSetPrototypeOf(ZlibBase.prototype, Transform.prototype); | |
@@ -487,7 +487,7 @@ function processChunkSync(self, chunk, flushFlag) { | |||
| 487 | 487 | ||
| 488 | 488 | function processChunk(self, chunk, flushFlag, cb) { | |
| 489 | 489 | const handle = self._handle; | |
| 490 | - assert(handle, 'zlib binding closed'); | ||
| 490 | + if (!handle) return process.nextTick(cb); | ||
| 491 | 491 | ||
| 492 | 492 | handle.buffer = chunk; | |
| 493 | 493 | handle.cb = cb; | |
@@ -513,13 +513,9 @@ function processCallback() { | |||
| 513 | 513 | const self = this[owner_symbol]; | |
| 514 | 514 | const state = self._writeState; | |
| 515 | 515 | ||
| 516 | - if (self._hadError) { | ||
| 517 | - this.buffer = null; | ||
| 518 | - return; | ||
| 519 | - } | ||
| 520 | - | ||
| 521 | - if (self.destroyed) { | ||
| 516 | + if (self._hadError || self.destroyed) { | ||
| 522 | 517 | this.buffer = null; | |
| 518 | + this.cb(); | ||
| 523 | 519 | return; | |
| 524 | 520 | } | |
| 525 | 521 | ||
@@ -539,6 +535,7 @@ function processCallback() { | |||
| 539 | 535 | } | |
| 540 | 536 | ||
| 541 | 537 | if (self.destroyed) { | |
| 538 | + this.cb(); | ||
| 542 | 539 | return; | |
| 543 | 540 | } | |
| 544 | 541 | ||
| 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