| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 651e7d2 commit 190ddce
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 | |
|---|---|---|---|
@@ -492,3 +492,26 @@ testClosed((opts) => new Writable({ write() {}, ...opts })); | |||
| 492 | 492 | .on('response', common.mustCall()); | |
| 493 | 493 | }); | |
| 494 | 494 | } | |
| 495 | + | ||
| 496 | + | ||
| 497 | + { | ||
| 498 | + const w = new Writable({ | ||
| 499 | + write(chunk, encoding, callback) { | ||
| 500 | + process.nextTick(callback); | ||
| 501 | + } | ||
| 502 | + }); | ||
| 503 | + w.aborted = false; | ||
| 504 | + w.end(); | ||
| 505 | + let closed = false; | ||
| 506 | + w.on('finish', () => { | ||
| 507 | + assert.strictEqual(closed, false); | ||
| 508 | + w.emit('aborted'); | ||
| 509 | + }); | ||
| 510 | + w.on('close', common.mustCall(() => { | ||
| 511 | + closed = true; | ||
| 512 | + })); | ||
| 513 | + | ||
| 514 | + finished(w, common.mustCall(() => { | ||
| 515 | + assert.strictEqual(closed, true); | ||
| 516 | + })); | ||
| 517 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments