mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
node-api: enable uncaught exceptions policy by default
This enables the option `--force-node-api-uncaught-exceptions-policy` for a specific Node-API addon when it is compiled with `NAPI_EXPERIMENTAL` (and this would be the default behavior when `NAPI_VERSION` 10 releases). This would not break existing Node-API addons. PR-URL: https://github.com/nodejs/node/pull/49313 Refs: https://github.com/nodejs/node/pull/36510 Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com>
This commit is contained in:
parent
448996cf95
commit
77597d3aea
16 changed files with 307 additions and 133 deletions
|
@ -1,27 +1,7 @@
|
|||
'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 binding = require(`./build/${common.buildType}/test_uncaught_exception`);
|
||||
const { testUncaughtException } = require('./uncaught_exception');
|
||||
|
||||
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');
|
||||
}),
|
||||
);
|
||||
testUncaughtException(binding);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue