From be59b67997a7ebd3fb440387d33e2e6bbf51404e Mon Sep 17 00:00:00 2001 From: legendecas Date: Mon, 19 Apr 2021 23:38:34 +0800 Subject: [PATCH] fixup!: fix checks with V8_ENABLE_CHECKS --- lib/internal/process/execution.js | 11 +++++++---- src/node_report.cc | 2 ++ .../test-report-uncaught-exception-primitives.js | 1 + test/report/test-report-uncaught-exception-symbols.js | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/internal/process/execution.js b/lib/internal/process/execution.js index e370770643ca6f..e2d9898012d2d7 100644 --- a/lib/internal/process/execution.js +++ b/lib/internal/process/execution.js @@ -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. } diff --git a/src/node_report.cc b/src/node_report.cc index ba88a0ecd58c1d..0144d22c17d13b 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -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; @@ -545,6 +546,7 @@ static void PrintJavaScriptErrorStack(JSONWriter* writer, Local error, const char* trigger) { TryCatch try_catch(isolate); + HandleScope scope(isolate); Local context = isolate->GetCurrentContext(); std::string ss = ""; if ((!strcmp(trigger, "FatalError")) || diff --git a/test/report/test-report-uncaught-exception-primitives.js b/test/report/test-report-uncaught-exception-primitives.js index 5b5e8f3893246b..75a05f335cf2e2 100644 --- a/test/report/test-report-uncaught-exception-primitives.js +++ b/test/report/test-report-uncaught-exception-primitives.js @@ -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}`], ]); })); diff --git a/test/report/test-report-uncaught-exception-symbols.js b/test/report/test-report-uncaught-exception-symbols.js index e86a243097ebdd..5997d0e0898ac0 100644 --- a/test/report/test-report-uncaught-exception-symbols.js +++ b/test/report/test-report-uncaught-exception-symbols.js @@ -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)'], ]); }));