Skip to content

async_hooks: fatalError(e) function checking error Object #38077

Closed
@PhakornKiong

Description

While going through the test coverage, I noticed that the else branch is actually not covered in the test case here

function fatalError(e) {
if (typeof e.stack === 'string') {
process._rawDebug(e.stack);
} else {
const o = { message: e };
ErrorCaptureStackTrace(o, fatalError);
process._rawDebug(o.stack);
}
const { getOptionValue } = require('internal/options');
if (getOptionValue('--abort-on-uncaught-exception')) {
process.abort();
}
process.exit(1);
}

Will the else case ever happened? According to the Node.js docs here, error.stack is always a string. So why would we ever do a check on that portion and have an else branch?

From what I understand, fatalError(e) is only used to capture error when the callback from the registered hooks failed and it doesn't seem necessary in this case.

Let me know what you think.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    async_hooksIssues and PRs related to the async hooks subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions