Skip to content

Commit

Permalink
void streams should continue the pack also
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh committed Jul 2, 2023
1 parent 6ed3778 commit aeb0e02
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ class Sink extends Writable {
if (this._pack._stream === this) this._continueOpen()
}

_continuePack (err) {
if (this._callback === null) return

const callback = this._callback
this._callback = null

callback(err)
}

_continueOpen () {
if (this._pack._stream === null) this._pack._stream = this

Expand All @@ -51,6 +60,7 @@ class Sink extends Writable {

if (this._isVoid) {
this._finish()
this._continuePack(null)
}

cb(null)
Expand Down Expand Up @@ -105,8 +115,7 @@ class Sink extends Writable {
_destroy (cb) {
this._pack._done(this)

if (this._finished) this._callback(null)
else this._callback(this._getError())
this._continuePack(this._finished ? null : this._getError())

cb()
}
Expand Down

0 comments on commit aeb0e02

Please sign in to comment.