| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8529864 commit c101e37
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -129,7 +129,9 @@ function eos(stream, options, callback) { | |||
| 129 | 129 | ||
| 130 | 130 | if (isRequest(stream)) { | |
| 131 | 131 | stream.on('complete', onfinish); | |
| 132 | - stream.on('abort', onclose); | ||
| 132 | + if (!willEmitClose) { | ||
| 133 | + stream.on('abort', onclose); | ||
| 134 | + } | ||
| 133 | 135 | if (stream.req) onrequest(); | |
| 134 | 136 | else stream.on('request', onrequest); | |
| 135 | 137 | } else if (writable && !wState) { // legacy streams | |
@@ -138,7 +140,7 @@ function eos(stream, options, callback) { | |||
| 138 | 140 | } | |
| 139 | 141 | ||
| 140 | 142 | // Not all streams will emit 'close' after 'aborted'. | |
| 141 | - if (typeof stream.aborted === 'boolean') { | ||
| 143 | + if (!willEmitClose && typeof stream.aborted === 'boolean') { | ||
| 142 | 144 | stream.on('aborted', onclose); | |
| 143 | 145 | } | |
| 144 | 146 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -473,3 +473,25 @@ testClosed((opts) => new Writable({ write() {}, ...opts })); | |||
| 473 | 473 | finished(p, common.mustNotCall()); | |
| 474 | 474 | })); | |
| 475 | 475 | } | |
| 476 | + | ||
| 477 | + { | ||
| 478 | + const w = new Writable({ | ||
| 479 | + write(chunk, encoding, callback) { | ||
| 480 | + process.nextTick(callback); | ||
| 481 | + } | ||
| 482 | + }); | ||
| 483 | + w.aborted = false; | ||
| 484 | + w.end(); | ||
| 485 | + let closed = false; | ||
| 486 | + w.on('finish', () => { | ||
| 487 | + assert.strictEqual(closed, false); | ||
| 488 | + w.emit('aborted'); | ||
| 489 | + }); | ||
| 490 | + w.on('close', common.mustCall(() => { | ||
| 491 | + closed = true; | ||
| 492 | + })); | ||
| 493 | + | ||
| 494 | + finished(w, common.mustCall(() => { | ||
| 495 | + assert.strictEqual(closed, true); | ||
| 496 | + })); | ||
| 497 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments