From 9e2763ddf157e9aa52a0cef5565eb792536a481a Mon Sep 17 00:00:00 2001 From: himself65 Date: Wed, 26 Jun 2019 19:17:29 +0800 Subject: [PATCH 1/3] src: correct json writer the place on process.report --- src/node_report.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/node_report.cc b/src/node_report.cc index 84caf13c5b64d1..cabf8cf6625090 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -366,7 +366,6 @@ static void PrintJavaScriptStack(JSONWriter* writer, int line = ss.find('\n'); if (line == -1) { writer->json_keyvalue("message", ss); - writer->json_objectend(); } else { std::string l = ss.substr(0, line); writer->json_keyvalue("message", l); @@ -382,8 +381,8 @@ static void PrintJavaScriptStack(JSONWriter* writer, ss = ss.substr(line + 1); line = ss.find('\n'); } + writer->json_arrayend(); } - writer->json_arrayend(); writer->json_objectend(); } From a8602c142c579b2555098358bf9be70d8f4a6ba7 Mon Sep 17 00:00:00 2001 From: himself65 Date: Wed, 26 Jun 2019 22:46:36 +0800 Subject: [PATCH 2/3] test: check writeReport when error with one line stack --- test/report/test-report-writereport.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/report/test-report-writereport.js b/test/report/test-report-writereport.js index 8a22600acfbec4..5ab3af0e299eee 100644 --- a/test/report/test-report-writereport.js +++ b/test/report/test-report-writereport.js @@ -37,6 +37,14 @@ function validate() { validate(); } +{ + // Test with an error with one line stack + const error = new Error(); + error.stack = 'only one line'; + process.report.writeReport(error); + validate(); +} + { // Test with a file argument. const file = process.report.writeReport('custom-name-1.json'); From ad0b6e3306f80f1ee8d53fb42948e270c4c42cd3 Mon Sep 17 00:00:00 2001 From: himself65 Date: Wed, 26 Jun 2019 22:53:24 +0800 Subject: [PATCH 3/3] test: check getReport when error with one line stack --- test/report/test-report-getreport.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/report/test-report-getreport.js b/test/report/test-report-getreport.js index 9f40e61c2e7efe..1ee844fa921354 100644 --- a/test/report/test-report-getreport.js +++ b/test/report/test-report-getreport.js @@ -21,6 +21,14 @@ common.expectWarning('ExperimentalWarning', assert.deepStrictEqual(helper.findReports(process.pid, process.cwd()), []); } +{ + // Test with an error with one line stack + const error = new Error(); + error.stack = 'only one line'; + helper.validateContent(process.report.getReport(error)); + assert.deepStrictEqual(helper.findReports(process.pid, process.cwd()), []); +} + // Test with an invalid error argument. [null, 1, Symbol(), function() {}, 'foo'].forEach((error) => { common.expectsError(() => {