summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-uncaught-from-request-callback.js
blob: 5c75958617898f19e297e7f1dd068caaa8ac79d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
const common = require('../common');
const asyncHooks = require('async_hooks');
const http = require('http');

// Regression test for https://github.com/nodejs/node/issues/31796

asyncHooks.createHook({
  after: () => {}
}).enable();


process.once('uncaughtException', common.mustCall(() => {
  server.close();
}));

const server = http.createServer(common.mustCall((request, response) => {
  response.writeHead(200, { 'Content-Type': 'text/plain' });
  response.end();
}));

server.listen(0, common.mustCall(() => {
  http.get({
    host: 'localhost',
    port: server.address().port
  }, common.mustCall(() => {
    throw new Error('whoah');
  }));
}));