| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2beb4f1 commit 1978285
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -908,6 +908,10 @@ OutgoingMessage.prototype.write = function write(chunk, encoding, callback) { | |||
| 908 | 908 | }; | |
| 909 | 909 | ||
| 910 | 910 | function onError(msg, err, callback) { | |
| 911 | + if (msg.destroyed) { | ||
| 912 | + return; | ||
| 913 | + } | ||
| 914 | + | ||
| 911 | 915 | const triggerAsyncId = msg.socket ? msg.socket[async_id_symbol] : undefined; | |
| 912 | 916 | defaultTriggerAsyncIdScope(triggerAsyncId, | |
| 913 | 917 | process.nextTick, | |
@@ -919,7 +923,7 @@ function onError(msg, err, callback) { | |||
| 919 | 923 | ||
| 920 | 924 | function emitErrorNt(msg, err, callback) { | |
| 921 | 925 | callback(err); | |
| 922 | - if (typeof msg.emit === 'function' && !msg._closed) { | ||
| 926 | + if (typeof msg.emit === 'function' && !msg.destroyed) { | ||
| 923 | 927 | msg.emit('error', err); | |
| 924 | 928 | } | |
| 925 | 929 | } | |
| 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