mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
fe43bd8ddd
ClientRequest could someone cause an unhandled error from socket. Fixes: https://github.com/nodejs/node/issues/36931 PR-URL: https://github.com/nodejs/node/pull/36970 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
33 lines
672 B
JavaScript
33 lines
672 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const http = require('http');
|
|
const net = require('net');
|
|
|
|
function createConnection() {
|
|
const socket = new net.Socket();
|
|
|
|
process.nextTick(function() {
|
|
socket.destroy(new Error('Oops'));
|
|
});
|
|
|
|
return socket;
|
|
}
|
|
|
|
{
|
|
const req = http.get({ createConnection });
|
|
|
|
req.on('error', common.expectsError({ name: 'Error', message: 'Oops' }));
|
|
req.abort();
|
|
}
|
|
|
|
{
|
|
class CustomAgent extends http.Agent {}
|
|
CustomAgent.prototype.createConnection = createConnection;
|
|
|
|
const req = http.get({ agent: new CustomAgent() });
|
|
|
|
req.on('error', common.expectsError({ name: 'Error', message: 'Oops' }));
|
|
req.abort();
|
|
}
|