Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 40b7e85

Browse files
committed
always forward errors on destroy. fixes mafintosh/tar-stream#39
1 parent fd1ddd1 commit 40b7e85

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,14 @@ exports.pack = function(cwd, opts) {
112112

113113
var entry = pack.entry(header, onnextentry)
114114
if (!entry) return
115-
var rs = xfs.createReadStream(path.join(cwd, filename))
116115

117-
pump(mapStream(rs, header), entry)
116+
var rs = mapStream(xfs.createReadStream(path.join(cwd, filename)), header)
117+
118+
rs.on('error', function(err) { // always forward errors on destroy
119+
entry.destroy(err)
120+
})
121+
122+
pump(rs, entry)
118123
}
119124

120125
var onnextentry = function(err) {
@@ -228,8 +233,13 @@ exports.extract = function(cwd, opts) {
228233

229234
var onfile = function() {
230235
var ws = xfs.createWriteStream(name)
236+
var rs = mapStream(stream, header)
237+
238+
ws.on('error', function(err) { // always forward errors on destroy
239+
rs.destroy(err)
240+
})
231241

232-
pump(mapStream(stream, header), ws, function(err) {
242+
pump(rs, ws, function(err) {
233243
if (err) return next(err)
234244
ws.on('close', stat)
235245
})

0 commit comments

Comments
 (0)