summaryrefslogtreecommitdiff
path: root/test/node-api/test_threadsafe_function/test_uncaught_exception.js
blob: 2529757908999b7324ee9a2fe1fe259b9a6a097d (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
'use strict';
// Flags: --force-node-api-uncaught-exceptions-policy

const common = require('../../common');
const assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);

const callbackCheck = common.mustCall((err) => {
  assert.throws(() => { throw err; }, /callback error/);
  process.removeListener('uncaughtException', callbackCheck);
  process.on('uncaughtException', finalizerCheck);
});
const finalizerCheck = common.mustCall((err) => {
  assert.throws(() => { throw err; }, /finalizer error/);
});
process.on('uncaughtException', callbackCheck);

binding.CallIntoModule(
  common.mustCall(() => {
    throw new Error('callback error');
  }),
  {},
  'resource_name',
  common.mustCall(function finalizer() {
    throw new Error('finalizer error');
  }),
);