mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 14:25:18 +00:00

Test uncaught exceptions when destroying IncomingMessage. PR-URL: https://github.com/nodejs/node/pull/33035 Refs: https://github.com/nodejs/node/issues/30625 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
26 lines
622 B
JavaScript
26 lines
622 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { createServer, get } = require('http');
|
|
const assert = require('assert');
|
|
|
|
const server = createServer(common.mustCall((req, res) => {
|
|
req.destroy(new Error('Destroy test'));
|
|
}));
|
|
|
|
function onUncaught(error) {}
|
|
|
|
process.on('uncaughtException', common.mustNotCall(onUncaught));
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
get({
|
|
port: server.address().port
|
|
}, (res) => {
|
|
res.resume();
|
|
}).on('error', (error) => {
|
|
assert.strictEqual(error.message, 'socket hang up');
|
|
assert.strictEqual(error.code, 'ECONNRESET');
|
|
server.close();
|
|
});
|
|
}));
|