node/test/parallel/test-domain-set-uncaught-exception-capture-after-load.js
Anna Henningsen 4503da8a3a
process: add flag for uncaught exception abort
Introduce `process.shouldAbortOnUncaughtException` to control
`--abort-on-uncaught-exception` behaviour, and implement
some of the domains functionality on top of it.

PR-URL: https://github.com/nodejs/node/pull/17159
Refs: https://github.com/nodejs/node/issues/17143
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
2017-11-29 15:58:42 +01:00

29 lines
726 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
(function foobar() {
require('domain');
})();
assert.throws(
() => process.setUncaughtExceptionCaptureCallback(common.mustNotCall()),
(err) => {
common.expectsError(
{
code: 'ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE',
type: Error,
message: /^The `domain` module is in use, which is mutually/
}
)(err);
assert(err.stack.includes('-'.repeat(40)),
`expected ${err.stack} to contain dashes`);
const location = `at foobar (${__filename}:`;
assert(err.stack.includes(location),
`expected ${err.stack} to contain ${location}`);
return true;
}
);