Skip to content

Commit

Permalink
fixup!: fix checks with V8_ENABLE_CHECKS
Browse files Browse the repository at this point in the history
  • Loading branch information
legendecas committed Apr 19, 2021
1 parent 386f07b commit be59b67
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/internal/process/execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,13 @@ function createOnGlobalUncaughtException() {
try {
const report = internalBinding('report');
if (report != null && report.shouldReportOnUncaughtException()) {
report.writeReport(er ? er.message : 'Exception',
'Exception',
null,
er ? er : {});
report.writeReport(
typeof er?.message === 'string' ?
er.message :
'Exception',
'Exception',
null,
er ? er : {});
}
} catch {} // Ignore the exception. Diagnostic reporting is unavailable.
}
Expand Down
2 changes: 2 additions & 0 deletions src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ using node::TIME_TYPE;
using node::worker::Worker;
using v8::Array;
using v8::Context;
using v8::HandleScope;
using v8::HeapSpaceStatistics;
using v8::HeapStatistics;
using v8::Isolate;
Expand Down Expand Up @@ -545,6 +546,7 @@ static void PrintJavaScriptErrorStack(JSONWriter* writer,
Local<Value> error,
const char* trigger) {
TryCatch try_catch(isolate);
HandleScope scope(isolate);
Local<Context> context = isolate->GetCurrentContext();
std::string ss = "";
if ((!strcmp(trigger, "FatalError")) ||
Expand Down
1 change: 1 addition & 0 deletions test/report/test-report-uncaught-exception-primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ process.on('uncaughtException', common.mustCall((err) => {
assert.strictEqual(reports.length, 1);
console.log(reports[0]);
helper.validate(reports[0], [
['header.event', 'Exception'],
['javascriptStack.message', `${exception}`],
]);
}));
Expand Down
1 change: 1 addition & 0 deletions test/report/test-report-uncaught-exception-symbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ process.on('uncaughtException', common.mustCall((err) => {
assert.strictEqual(reports.length, 1);
console.log(reports[0]);
helper.validate(reports[0], [
['header.event', 'Exception'],
['javascriptStack.message', 'Symbol(foobar)'],
]);
}));
Expand Down

0 comments on commit be59b67

Please sign in to comment.