| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2ba547a commit 5355a46
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -784,21 +784,8 @@ static void PrintRelease(JSONWriter* writer) { | |||
| 784 | 784 | ||
| 785 | 785 | } // namespace report | |
| 786 | 786 | ||
| 787 | - // External function to trigger a report, writing to file. | ||
| 788 | 787 | std::string TriggerNodeReport(Isolate* isolate, | |
| 789 | - const char* message, | ||
| 790 | - const char* trigger, | ||
| 791 | - const std::string& name, | ||
| 792 | - Local<Value> error) { | ||
| 793 | - Environment* env = nullptr; | ||
| 794 | - if (isolate != nullptr) { | ||
| 795 | - env = Environment::GetCurrent(isolate); | ||
| 796 | - } | ||
| 797 | - return TriggerNodeReport(env, message, trigger, name, error); | ||
| 798 | - } | ||
| 799 | - | ||
| 800 | - // External function to trigger a report, writing to file. | ||
| 801 | - std::string TriggerNodeReport(Environment* env, | ||
| 788 | + Environment* env, | ||
| 802 | 789 | const char* message, | |
| 803 | 790 | const char* trigger, | |
| 804 | 791 | const std::string& name, | |
@@ -868,10 +855,6 @@ std::string TriggerNodeReport(Environment* env, | |||
| 868 | 855 | compact = per_process::cli_options->report_compact; | |
| 869 | 856 | } | |
| 870 | 857 | ||
| 871 | - Isolate* isolate = nullptr; | ||
| 872 | - if (env != nullptr) { | ||
| 873 | - isolate = env->isolate(); | ||
| 874 | - } | ||
| 875 | 858 | report::WriteNodeReport( | |
| 876 | 859 | isolate, env, message, trigger, filename, *outstream, error, compact); | |
| 877 | 860 | ||
@@ -887,6 +870,33 @@ std::string TriggerNodeReport(Environment* env, | |||
| 887 | 870 | return filename; | |
| 888 | 871 | } | |
| 889 | 872 | ||
| 873 | + // External function to trigger a report, writing to file. | ||
| 874 | + std::string TriggerNodeReport(Isolate* isolate, | ||
| 875 | + const char* message, | ||
| 876 | + const char* trigger, | ||
| 877 | + const std::string& name, | ||
| 878 | + Local<Value> error) { | ||
| 879 | + Environment* env = nullptr; | ||
| 880 | + if (isolate != nullptr) { | ||
| 881 | + env = Environment::GetCurrent(isolate); | ||
| 882 | + } | ||
| 883 | + return TriggerNodeReport(isolate, env, message, trigger, name, error); | ||
| 884 | + } | ||
| 885 | + | ||
| 886 | + // External function to trigger a report, writing to file. | ||
| 887 | + std::string TriggerNodeReport(Environment* env, | ||
| 888 | + const char* message, | ||
| 889 | + const char* trigger, | ||
| 890 | + const std::string& name, | ||
| 891 | + Local<Value> error) { | ||
| 892 | + return TriggerNodeReport(env != nullptr ? env->isolate() : nullptr, | ||
| 893 | + env, | ||
| 894 | + message, | ||
| 895 | + trigger, | ||
| 896 | + name, | ||
| 897 | + error); | ||
| 898 | + } | ||
| 899 | + | ||
| 890 | 900 | // External function to trigger a report, writing to a supplied stream. | |
| 891 | 901 | void GetNodeReport(Isolate* isolate, | |
| 892 | 902 | const char* message, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,9 +12,13 @@ const fixtures = require('../common/fixtures'); | |||
| 12 | 12 | ||
| 13 | 13 | // Common args that will cause an out-of-memory error for child process. | |
| 14 | 14 | const ARGS = [ | |
| 15 | - '--max-old-space-size=20', | ||
| 15 | + '--max-heap-size=20', | ||
| 16 | 16 | fixtures.path('report-oom'), | |
| 17 | 17 | ]; | |
| 18 | + const REPORT_FIELDS = [ | ||
| 19 | + ['header.trigger', 'OOMError'], | ||
| 20 | + ['javascriptHeap.memoryLimit', 20 * 1024 * 1024 /* 20MB */], | ||
| 21 | + ]; | ||
| 18 | 22 | ||
| 19 | 23 | { | |
| 20 | 24 | // Verify that --report-compact is respected when set. | |
@@ -27,8 +31,8 @@ const ARGS = [ | |||
| 27 | 31 | assert.strictEqual(reports.length, 1); | |
| 28 | 32 | ||
| 29 | 33 | const report = reports[0]; | |
| 30 | - helper.validate(report); | ||
| 31 | - assert.strictEqual(require(report).header.threadId, null); | ||
| 34 | + helper.validate(report, REPORT_FIELDS); | ||
| 35 | + | ||
| 32 | 36 | // Subtract 1 because "xx\n".split("\n") => [ 'xx', '' ]. | |
| 33 | 37 | const lines = fs.readFileSync(report, 'utf8').split('\n').length - 1; | |
| 34 | 38 | assert.strictEqual(lines, 1); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,9 +12,13 @@ const fixtures = require('../common/fixtures'); | |||
| 12 | 12 | ||
| 13 | 13 | // Common args that will cause an out-of-memory error for child process. | |
| 14 | 14 | const ARGS = [ | |
| 15 | - '--max-old-space-size=20', | ||
| 15 | + '--max-heap-size=20', | ||
| 16 | 16 | fixtures.path('report-oom'), | |
| 17 | 17 | ]; | |
| 18 | + const REPORT_FIELDS = [ | ||
| 19 | + ['header.trigger', 'OOMError'], | ||
| 20 | + ['javascriptHeap.memoryLimit', 20 * 1024 * 1024 /* 20MB */], | ||
| 21 | + ]; | ||
| 18 | 22 | ||
| 19 | 23 | { | |
| 20 | 24 | // Verify that --report-directory is respected when set. | |
@@ -29,8 +33,8 @@ const ARGS = [ | |||
| 29 | 33 | assert.strictEqual(reports.length, 1); | |
| 30 | 34 | ||
| 31 | 35 | const report = reports[0]; | |
| 32 | - helper.validate(report); | ||
| 33 | - assert.strictEqual(require(report).header.threadId, null); | ||
| 36 | + helper.validate(report, REPORT_FIELDS); | ||
| 37 | + | ||
| 34 | 38 | const lines = fs.readFileSync(report, 'utf8').split('\n').length - 1; | |
| 35 | 39 | assert(lines > 10); | |
| 36 | 40 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,9 +11,13 @@ const fixtures = require('../common/fixtures'); | |||
| 11 | 11 | ||
| 12 | 12 | // Common args that will cause an out-of-memory error for child process. | |
| 13 | 13 | const ARGS = [ | |
| 14 | - '--max-old-space-size=20', | ||
| 14 | + '--max-heap-size=20', | ||
| 15 | 15 | fixtures.path('report-oom'), | |
| 16 | 16 | ]; | |
| 17 | + const REPORT_FIELDS = [ | ||
| 18 | + ['header.trigger', 'OOMError'], | ||
| 19 | + ['javascriptHeap.memoryLimit', 20 * 1024 * 1024 /* 20MB */], | ||
| 20 | + ]; | ||
| 17 | 21 | ||
| 18 | 22 | { | |
| 19 | 23 | // Verify that --report-compact is respected when set. | |
@@ -34,7 +38,5 @@ const ARGS = [ | |||
| 34 | 38 | const lines = child.stderr.split('\n'); | |
| 35 | 39 | // Skip over unavoidable free-form output and gc log from V8. | |
| 36 | 40 | const report = lines.find((i) => i.startsWith('{')); | |
| 37 | - const json = JSON.parse(report); | ||
| 38 | - | ||
| 39 | - assert.strictEqual(json.header.threadId, null); | ||
| 41 | + helper.validateContent(report, REPORT_FIELDS); | ||
| 40 | 42 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ const fixtures = require('../common/fixtures'); | |||
| 11 | 11 | ||
| 12 | 12 | // Common args that will cause an out-of-memory error for child process. | |
| 13 | 13 | const ARGS = [ | |
| 14 | - '--max-old-space-size=20', | ||
| 14 | + '--max-heap-size=20', | ||
| 15 | 15 | fixtures.path('report-oom'), | |
| 16 | 16 | ]; | |
| 17 | 17 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,9 +11,13 @@ const fixtures = require('../common/fixtures'); | |||
| 11 | 11 | ||
| 12 | 12 | // Common args that will cause an out-of-memory error for child process. | |
| 13 | 13 | const ARGS = [ | |
| 14 | - '--max-old-space-size=20', | ||
| 14 | + '--max-heap-size=20', | ||
| 15 | 15 | fixtures.path('report-oom'), | |
| 16 | 16 | ]; | |
| 17 | + const REPORT_FIELDS = [ | ||
| 18 | + ['header.trigger', 'OOMError'], | ||
| 19 | + ['javascriptHeap.memoryLimit', 20 * 1024 * 1024 /* 20MB */], | ||
| 20 | + ]; | ||
| 17 | 21 | ||
| 18 | 22 | { | |
| 19 | 23 | // Verify that --report-on-fatalerror is respected when set. | |
@@ -26,12 +30,5 @@ const ARGS = [ | |||
| 26 | 30 | assert.strictEqual(reports.length, 1); | |
| 27 | 31 | ||
| 28 | 32 | const report = reports[0]; | |
| 29 | - helper.validate(report); | ||
| 30 | - | ||
| 31 | - const content = require(report); | ||
| 32 | - // Errors occur in a context where env is not available, so thread ID is | ||
| 33 | - // unknown. Assert this, to verify that the underlying env-less situation is | ||
| 34 | - // actually reached. | ||
| 35 | - assert.strictEqual(content.header.threadId, null); | ||
| 36 | - assert.strictEqual(content.header.trigger, 'OOMError'); | ||
| 33 | + helper.validate(report, REPORT_FIELDS); | ||
| 37 | 34 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments