| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e87db6c commit 674b932
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -864,6 +864,10 @@ OutgoingMessage.prototype.write = function write(chunk, encoding, callback) { | |||
| 864 | 864 | }; | |
| 865 | 865 | ||
| 866 | 866 | function onError(msg, err, callback) { | |
| 867 | + if (msg.destroyed) { | ||
| 868 | + return; | ||
| 869 | + } | ||
| 870 | + | ||
| 867 | 871 | const triggerAsyncId = msg.socket ? msg.socket[async_id_symbol] : undefined; | |
| 868 | 872 | defaultTriggerAsyncIdScope(triggerAsyncId, | |
| 869 | 873 | process.nextTick, | |
@@ -875,7 +879,7 @@ function onError(msg, err, callback) { | |||
| 875 | 879 | ||
| 876 | 880 | function emitErrorNt(msg, err, callback) { | |
| 877 | 881 | callback(err); | |
| 878 | - if (typeof msg.emit === 'function' && !msg._closed) { | ||
| 882 | + if (typeof msg.emit === 'function' && !msg.destroyed) { | ||
| 879 | 883 | msg.emit('error', err); | |
| 880 | 884 | } | |
| 881 | 885 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,5 +51,27 @@ const assert = require('assert'); | |||
| 51 | 51 | .on('error', common.mustCall()) | |
| 52 | 52 | .write('asd'); | |
| 53 | 53 | }); | |
| 54 | + } | ||
| 54 | 55 | ||
| 56 | + { | ||
| 57 | + const server = http.createServer(common.mustCall((req, res) => { | ||
| 58 | + assert.strictEqual(res.closed, false); | ||
| 59 | + res.end(); | ||
| 60 | + res.destroy(); | ||
| 61 | + // Make sure not to emit 'error' after .destroy(). | ||
| 62 | + res.end('asd'); | ||
| 63 | + assert.strictEqual(res.errored, undefined); | ||
| 64 | + })).listen(0, () => { | ||
| 65 | + http | ||
| 66 | + .request({ | ||
| 67 | + port: server.address().port, | ||
| 68 | + method: 'GET' | ||
| 69 | + }) | ||
| 70 | + .on('response', common.mustCall((res) => { | ||
| 71 | + res.resume().on('end', common.mustCall(() => { | ||
| 72 | + server.close(); | ||
| 73 | + })); | ||
| 74 | + })) | ||
| 75 | + .end(); | ||
| 76 | + }); | ||
| 55 | 77 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments