GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http: don't emit error after destroy · nodejs/node@1978285

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • _http_outgoing.js
  • test/parallel
    • test-http-outgoing-destroyed.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/_http_outgoing.js‎

Copy file name to clipboardExpand all lines: lib/_http_outgoing.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,10 @@ OutgoingMessage.prototype.write = function write(chunk, encoding, callback) {
908908
};
909909

910910
function onError(msg, err, callback) {
911+
if (msg.destroyed) {
912+
return;
913+
}
914+
911915
const triggerAsyncId = msg.socket ? msg.socket[async_id_symbol] : undefined;
912916
defaultTriggerAsyncIdScope(triggerAsyncId,
913917
process.nextTick,
@@ -919,7 +923,7 @@ function onError(msg, err, callback) {
919923

920924
function emitErrorNt(msg, err, callback) {
921925
callback(err);
922-
if (typeof msg.emit === 'function' && !msg._closed) {
926+
if (typeof msg.emit === 'function' && !msg.destroyed) {
923927
msg.emit('error', err);
924928
}
925929
}
Collapse file

‎test/parallel/test-http-outgoing-destroyed.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-outgoing-destroyed.js
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,27 @@ const assert = require('assert');
5151
.on('error', common.mustCall())
5252
.write('asd');
5353
});
54+
}
5455

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+
});
5577
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.