-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When emitting a 'connection' event on a httpServer, the function connectionListener is called. Then, a new parser is created, and 'consume' method is called on the socket's externalStream. However, if this stream was already consumed and unconsumed, the process crashes with a cpp assert from the 'Consume' method in stream_base.h. This commit makes sure that no SIGABRT will be raised and the process will stay alive (after emitting the socket).
- Loading branch information
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const http = require('http'); | ||
|
||
const testServer = http.createServer((req, res) => { | ||
common.fail('Should not be called'); | ||
res.end(); | ||
}); | ||
testServer.on('connect', common.mustCall((req, socket, head) => { | ||
socket.write('HTTP/1.1 200 Connection Established' + '\r\n' + | ||
'Proxy-agent: Node-Proxy' + '\r\n' + | ||
'\r\n'); | ||
// This shouldn't raise an assertion in StreamBase::Consume. | ||
testServer.emit('connection', socket); | ||
testServer.close(); | ||
})); | ||
testServer.listen(0, common.mustCall(() => { | ||
http.request({ | ||
port: testServer.address().port, | ||
method: 'CONNECT' | ||
}, (res) => {}).end(); | ||
})); |