Skip to content

domains: errors thrown within domains without error handlers cause node to abort at the wrong time when using --abort-on-uncaught-exception #3653

Closed
@misterdjules

Description

When throwing an error from a domain that doesn't have an error handler set, and when using --abort-on-uncaught-exception, instead of aborting at the time the error is thrown, node aborts when trying to emit the error event on the domain because there's no handler for that event:

$ node --version
v4.2.1
$ cat /tmp/domain-throw-no-error-handler.js 
const domain = require('domain');
const d = domain.create();

d.run(function() {
    throw new Error('boom');
});
$ node --abort-on-uncaught-exception /tmp/domain-throw-no-error-handler.js 
Uncaught Error: boom

FROM
Domain.emit (events.js:141:7)
emitError (domain.js:65:24)
Domain.errorHandler [as _errorHandler] (domain.js:104:16)
process._fatalException (node.js:218:33)
[1]    99899 illegal hardware instruction  node --abort-on-uncaught-exception /tmp/domain-throw-no-error-handler.js
$

This can be reproduced on v0.10.40, the tip of the v0.12 branch, v4.2.1 and I suspect v5.x and nodejs/node's master.

Metadata

Assignees

No one assigned

    Labels

    domainIssues and PRs related to the domain subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions