Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/_http_agent.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -276,7 +276,6 @@ function installListeners(agent, s, options){
s.removeListener('close', onClose);
s.removeListener('free', onFree);
s.removeListener('agentRemove', onRemove);
s._httpMessage = null;
}
s.on('agentRemove', onRemove);
}
Expand Down
1 change: 1 addition & 0 deletions lib/_http_client.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -467,6 +467,7 @@ function socketOnData(d){
socket.removeListener('close', socketCloseListener);
socket.removeListener('error', socketErrorListener);

socket._httpMessage = null;
socket.readableFlowing = null;

req.emit(eventName, res, socket, bodyHead);
Expand Down
21 changes: 21 additions & 0 deletions test/parallel/test-http-agent-remove.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
'use strict'
const{mustCall } = require('../common');

const http = require('http');
const{strictEqual } = require('assert');

const server = http.createServer(mustCall((req, res) =>{
res.flushHeaders();
}));

server.listen(0, mustCall(() =>{
const req = http.get({
port: server.address().port
}, mustCall(() =>{
const{socket } = req;
socket.emit('agentRemove');
strictEqual(socket._httpMessage, req);
socket.destroy();
server.close();
}));
}));