Closed as not planned
Description
- Version: v10.5.0
- Platform: Linux pc 4.13.0-41-generic # 46~16.04.1-Ubuntu SMP Thu May 3 10:06:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
- Subsystem:
const domain = require('domain');
function captureUncaughtException() {
const createdDomain = domain.create();
createdDomain.on('error', () => console.log('Caught error within the domain!'));
createdDomain.run(notExistingFn);
}
process.on('uncaughtException', captureUncaughtException.bind(this));
throw new Error();
// Expected output:
// Caught error within the domain!
// Actual output:
// ReferenceError: notExistingFn is not defined
And on contrary to the above scenario, if we call captureUncaughtException()
directly, it behaves normally.
captureUncaughtException();
// Output:
// Caught error within the domain!