Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: correct json writer the place on process.report #28433

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
}

Expand Down
8 changes: 8 additions & 0 deletions test/report/test-report-getreport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
8 changes: 8 additions & 0 deletions test/report/test-report-writereport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
himself65 marked this conversation as resolved.
Show resolved Hide resolved
validate();
}

{
// Test with a file argument.
const file = process.report.writeReport('custom-name-1.json');
Expand Down