GeezerVison is showing github.com — report: disable js stack when no context is entered · nodejs/node@bdcc037
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/node_report.cc +8-2Lines changed: 8 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -66,6 +66,7 @@ static void PrintJavaScriptErrorStack(JSONWriter* writer, | 66 | 66 | Isolate* isolate, | 67 | 67 | Local<Value> error, | 68 | 68 | const char* trigger); | | 69 | +static void PrintEmptyJavaScriptStack(JSONWriter* writer); | 69 | 70 | static void PrintJavaScriptStack(JSONWriter* writer, | 70 | 71 | Isolate* isolate, | 71 | 72 | const char* trigger); | @@ -184,6 +185,10 @@ static void WriteNodeReport(Isolate* isolate, | 184 | 185 |
| 185 | 186 | // Report V8 Heap and Garbage Collector information | 186 | 187 | PrintGCStatistics(&writer, isolate); | | 188 | + } else { | | 189 | + writer.json_objectstart("javascriptStack"); | | 190 | + PrintEmptyJavaScriptStack(&writer); | | 191 | + writer.json_objectend(); // the end of 'javascriptStack' | 187 | 192 | } | 188 | 193 |
| 189 | 194 | // Report native stack backtrace | @@ -452,8 +457,9 @@ static void PrintEmptyJavaScriptStack(JSONWriter* writer) { | 452 | 457 | static void PrintJavaScriptStack(JSONWriter* writer, | 453 | 458 | Isolate* isolate, | 454 | 459 | const char* trigger) { | 455 | | - // Can not capture the stacktrace when the isolate is in a OOM state. | 456 | | - if (!strcmp(trigger, "OOMError")) { | | 460 | + // Can not capture the stacktrace when the isolate is in a OOM state or no | | 461 | + // context is entered. | | 462 | + if (!strcmp(trigger, "OOMError") || !isolate->InContext()) { | 457 | 463 | PrintEmptyJavaScriptStack(writer); | 458 | 464 | return; | 459 | 465 | } | |
Collapse file Copy file name to clipboardExpand all lines: test/addons/report-api/test.js +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,7 +9,7 @@ const tmpdir = require('../../common/tmpdir'); | 9 | 9 | const binding = path.resolve(__dirname, `./build/${common.buildType}/binding`); | 10 | 10 | const addon = require(binding); | 11 | 11 |
| 12 | | -function myAddonMain(method, { hasIsolate, hasEnv }) { | | 12 | +function myAddonMain(method, { hasContext, hasEnv }) { | 13 | 13 | tmpdir.refresh(); | 14 | 14 | process.report.directory = tmpdir.path; | 15 | 15 |
| @@ -27,10 +27,10 @@ function myAddonMain(method, { hasIsolate, hasEnv }) { | 27 | 27 | const content = require(report); | 28 | 28 |
| 29 | 29 | // Check that the javascript stack is present. | 30 | | - if (hasIsolate) { | | 30 | + if (hasContext) { | 31 | 31 | assert.strictEqual(content.javascriptStack.stack.findIndex((frame) => frame.match('myAddonMain')), 0); | 32 | 32 | } else { | 33 | | - assert.strictEqual(content.javascriptStack, undefined); | | 33 | + assert.strictEqual(content.javascriptStack.message, 'No stack.'); | 34 | 34 | } | 35 | 35 |
| 36 | 36 | if (hasEnv) { | @@ -45,9 +45,9 @@ const methods = [ | 45 | 45 | ['triggerReportNoIsolate', false, false], | 46 | 46 | ['triggerReportEnv', true, true], | 47 | 47 | ['triggerReportNoEnv', false, false], | 48 | | - ['triggerReportNoContext', true, false], | | 48 | + ['triggerReportNoContext', false, false], | 49 | 49 | ['triggerReportNewContext', true, false], | 50 | 50 | ]; | 51 | | -for (const [method, hasIsolate, hasEnv] of methods) { | 52 | | - myAddonMain(method, { hasIsolate, hasEnv }); | | 51 | +for (const [method, hasContext, hasEnv] of methods) { | | 52 | + myAddonMain(method, { hasContext, hasEnv }); | 53 | 53 | } |
Collapse file Copy file name to clipboardExpand all lines: test/common/report.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -55,19 +55,19 @@ function validateContent(report, fields = []) { | 55 | 55 |
| 56 | 56 | function _validateContent(report, fields = []) { | 57 | 57 | const isWindows = process.platform === 'win32'; | 58 | | - const isJavaScriptThreadReport = report.javascriptStack != null; | | 58 | + const isJavaScriptThreadReport = report.javascriptHeap != null; | 59 | 59 |
| 60 | 60 | // Verify that all sections are present as own properties of the report. | 61 | | - const sections = ['header', 'nativeStack', 'libuv', 'environmentVariables', | 62 | | - 'sharedObjects', 'resourceUsage', 'workers']; | | 61 | + const sections = ['header', 'nativeStack', 'javascriptStack', 'libuv', | | 62 | + 'environmentVariables', 'sharedObjects', 'resourceUsage', 'workers']; | 63 | 63 | if (!isWindows) | 64 | 64 | sections.push('userLimits'); | 65 | 65 |
| 66 | 66 | if (report.uvthreadResourceUsage) | 67 | 67 | sections.push('uvthreadResourceUsage'); | 68 | 68 |
| 69 | 69 | if (isJavaScriptThreadReport) | 70 | | - sections.push('javascriptStack', 'javascriptHeap'); | | 70 | + sections.push('javascriptHeap'); | 71 | 71 |
| 72 | 72 | checkForUnknownFields(report, sections); | 73 | 73 | sections.forEach((section) => { | |
|