| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c736927 commit 0c76e01
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,13 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const list = []; | ||
| 4 | + while (true) { | ||
| 5 | + const record = new MyRecord(); | ||
| 6 | + list.push(record); | ||
| 7 | + } | ||
| 8 | + | ||
| 9 | + function MyRecord() { | ||
| 10 | + this.name = 'foo'; | ||
| 11 | + this.id = 128; | ||
| 12 | + this.account = 98454324; | ||
| 13 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,35 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + // Testcases for situations involving fatal errors, like Javascript heap OOM | ||
| 4 | + | ||
| 5 | + require('../common'); | ||
| 6 | + const assert = require('assert'); | ||
| 7 | + const fs = require('fs'); | ||
| 8 | + const helper = require('../common/report.js'); | ||
| 9 | + const spawnSync = require('child_process').spawnSync; | ||
| 10 | + const tmpdir = require('../common/tmpdir'); | ||
| 11 | + const fixtures = require('../common/fixtures'); | ||
| 12 | + | ||
| 13 | + // Common args that will cause an out-of-memory error for child process. | ||
| 14 | + const ARGS = [ | ||
| 15 | + '--max-old-space-size=20', | ||
| 16 | + fixtures.path('report-oom'), | ||
| 17 | + ]; | ||
| 18 | + | ||
| 19 | + { | ||
| 20 | + // Verify that --report-compact is respected when set. | ||
| 21 | + tmpdir.refresh(); | ||
| 22 | + const args = ['--report-on-fatalerror', '--report-compact', ...ARGS]; | ||
| 23 | + const child = spawnSync(process.execPath, args, { cwd: tmpdir.path }); | ||
| 24 | + assert.notStrictEqual(child.status, 0, 'Process exited unexpectedly'); | ||
| 25 | + | ||
| 26 | + const reports = helper.findReports(child.pid, tmpdir.path); | ||
| 27 | + assert.strictEqual(reports.length, 1); | ||
| 28 | + | ||
| 29 | + const report = reports[0]; | ||
| 30 | + helper.validate(report); | ||
| 31 | + assert.strictEqual(require(report).header.threadId, null); | ||
| 32 | + // Subtract 1 because "xx\n".split("\n") => [ 'xx', '' ]. | ||
| 33 | + const lines = fs.readFileSync(report, 'utf8').split('\n').length - 1; | ||
| 34 | + assert.strictEqual(lines, 1); | ||
| 35 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,36 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + // Testcases for situations involving fatal errors, like Javascript heap OOM | ||
| 4 | + | ||
| 5 | + require('../common'); | ||
| 6 | + const assert = require('assert'); | ||
| 7 | + const fs = require('fs'); | ||
| 8 | + const helper = require('../common/report.js'); | ||
| 9 | + const spawnSync = require('child_process').spawnSync; | ||
| 10 | + const tmpdir = require('../common/tmpdir'); | ||
| 11 | + const fixtures = require('../common/fixtures'); | ||
| 12 | + | ||
| 13 | + // Common args that will cause an out-of-memory error for child process. | ||
| 14 | + const ARGS = [ | ||
| 15 | + '--max-old-space-size=20', | ||
| 16 | + fixtures.path('report-oom'), | ||
| 17 | + ]; | ||
| 18 | + | ||
| 19 | + { | ||
| 20 | + // Verify that --report-directory is respected when set. | ||
| 21 | + // Verify that --report-compact is respected when not set. | ||
| 22 | + tmpdir.refresh(); | ||
| 23 | + const dir = '--report-directory=' + tmpdir.path; | ||
| 24 | + const args = ['--report-on-fatalerror', dir, ...ARGS]; | ||
| 25 | + const child = spawnSync(process.execPath, args, { }); | ||
| 26 | + assert.notStrictEqual(child.status, 0, 'Process exited unexpectedly'); | ||
| 27 | + | ||
| 28 | + const reports = helper.findReports(child.pid, tmpdir.path); | ||
| 29 | + assert.strictEqual(reports.length, 1); | ||
| 30 | + | ||
| 31 | + const report = reports[0]; | ||
| 32 | + helper.validate(report); | ||
| 33 | + assert.strictEqual(require(report).header.threadId, null); | ||
| 34 | + const lines = fs.readFileSync(report, 'utf8').split('\n').length - 1; | ||
| 35 | + assert(lines > 10); | ||
| 36 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,40 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + // Testcases for situations involving fatal errors, like Javascript heap OOM | ||
| 4 | + | ||
| 5 | + require('../common'); | ||
| 6 | + const assert = require('assert'); | ||
| 7 | + const helper = require('../common/report.js'); | ||
| 8 | + const spawnSync = require('child_process').spawnSync; | ||
| 9 | + const tmpdir = require('../common/tmpdir'); | ||
| 10 | + const fixtures = require('../common/fixtures'); | ||
| 11 | + | ||
| 12 | + // Common args that will cause an out-of-memory error for child process. | ||
| 13 | + const ARGS = [ | ||
| 14 | + '--max-old-space-size=20', | ||
| 15 | + fixtures.path('report-oom'), | ||
| 16 | + ]; | ||
| 17 | + | ||
| 18 | + { | ||
| 19 | + // Verify that --report-compact is respected when set. | ||
| 20 | + // Verify that --report-filename is respected when set. | ||
| 21 | + tmpdir.refresh(); | ||
| 22 | + const args = [ | ||
| 23 | + '--report-on-fatalerror', | ||
| 24 | + '--report-compact', | ||
| 25 | + '--report-filename=stderr', | ||
| 26 | + ...ARGS, | ||
| 27 | + ]; | ||
| 28 | + const child = spawnSync(process.execPath, args, { encoding: 'utf8' }); | ||
| 29 | + assert.notStrictEqual(child.status, 0, 'Process exited unexpectedly'); | ||
| 30 | + | ||
| 31 | + const reports = helper.findReports(child.pid, tmpdir.path); | ||
| 32 | + assert.strictEqual(reports.length, 0); | ||
| 33 | + | ||
| 34 | + const lines = child.stderr.split('\n'); | ||
| 35 | + // Skip over unavoidable free-form output and gc log from V8. | ||
| 36 | + const report = lines.find((i) => i.startsWith('{')); | ||
| 37 | + const json = JSON.parse(report); | ||
| 38 | + | ||
| 39 | + assert.strictEqual(json.header.threadId, null); | ||
| 40 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,26 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + // Testcases for situations involving fatal errors, like Javascript heap OOM | ||
| 4 | + | ||
| 5 | + require('../common'); | ||
| 6 | + const assert = require('assert'); | ||
| 7 | + const helper = require('../common/report.js'); | ||
| 8 | + const spawnSync = require('child_process').spawnSync; | ||
| 9 | + const tmpdir = require('../common/tmpdir'); | ||
| 10 | + const fixtures = require('../common/fixtures'); | ||
| 11 | + | ||
| 12 | + // Common args that will cause an out-of-memory error for child process. | ||
| 13 | + const ARGS = [ | ||
| 14 | + '--max-old-space-size=20', | ||
| 15 | + fixtures.path('report-oom'), | ||
| 16 | + ]; | ||
| 17 | + | ||
| 18 | + { | ||
| 19 | + tmpdir.refresh(); | ||
| 20 | + // Verify that --report-on-fatalerror is respected when not set. | ||
| 21 | + const args = ARGS; | ||
| 22 | + const child = spawnSync(process.execPath, args, { cwd: tmpdir.path }); | ||
| 23 | + assert.notStrictEqual(child.status, 0, 'Process exited unexpectedly'); | ||
| 24 | + const reports = helper.findReports(child.pid, tmpdir.path); | ||
| 25 | + assert.strictEqual(reports.length, 0); | ||
| 26 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,37 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + // Testcases for situations involving fatal errors, like Javascript heap OOM | ||
| 4 | + | ||
| 5 | + require('../common'); | ||
| 6 | + const assert = require('assert'); | ||
| 7 | + const helper = require('../common/report.js'); | ||
| 8 | + const spawnSync = require('child_process').spawnSync; | ||
| 9 | + const tmpdir = require('../common/tmpdir'); | ||
| 10 | + const fixtures = require('../common/fixtures'); | ||
| 11 | + | ||
| 12 | + // Common args that will cause an out-of-memory error for child process. | ||
| 13 | + const ARGS = [ | ||
| 14 | + '--max-old-space-size=20', | ||
| 15 | + fixtures.path('report-oom'), | ||
| 16 | + ]; | ||
| 17 | + | ||
| 18 | + { | ||
| 19 | + // Verify that --report-on-fatalerror is respected when set. | ||
| 20 | + tmpdir.refresh(); | ||
| 21 | + const args = ['--report-on-fatalerror', ...ARGS]; | ||
| 22 | + const child = spawnSync(process.execPath, args, { cwd: tmpdir.path }); | ||
| 23 | + assert.notStrictEqual(child.status, 0, 'Process exited unexpectedly'); | ||
| 24 | + | ||
| 25 | + const reports = helper.findReports(child.pid, tmpdir.path); | ||
| 26 | + assert.strictEqual(reports.length, 1); | ||
| 27 | + | ||
| 28 | + 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'); | ||
| 37 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments