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.
While going through the test coverage, I noticed that the
elsebranch is actually not covered in the test case herenode/lib/internal/async_hooks.js
Lines 160 to 174 in 17a527e
Will the else case ever happened? According to the Node.js docs here,
error.stackis always astring. So why would we ever do a check on that portion and have anelsebranch?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.