Skip to content

Commit b43a920

Browse files
authored
Protect against end after destroy (#34)
1 parent 5a59a72 commit b43a920

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ Duplexify.prototype.end = function(data, enc, cb) {
231231
if (typeof enc === 'function') return this.end(data, null, enc)
232232
this._ended = true
233233
if (data) this.write(data)
234-
if (!this._writableState.ending) this.write(SIGNAL_FLUSH)
234+
if (!this._writableState.ending && !this._writableState.destroyed) this.write(SIGNAL_FLUSH)
235235
return stream.Writable.prototype.end.call(this, cb)
236236
}
237237

test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ tape('destroy', function(t) {
137137

138138
dup.destroy()
139139
dup.destroy() // should only work once
140+
dup.end()
140141
})
141142

142143
tape('destroy both', function(t) {

0 commit comments

Comments
 (0)