-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include a report for each sub-Worker of the current Node.js instance. This adds a feature that is necessary for eventually making the report feature stable, as was discussed during the last collaborator summit. Refs: openjs-foundation/summit#240 PR-URL: #31386 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
- Loading branch information
1 parent
f56de5a
commit 1bcf2f9
Showing
8 changed files
with
161 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Flags: --experimental-report | ||
'use strict'; | ||
const common = require('../common'); | ||
common.skipIfReportDisabled(); | ||
const assert = require('assert'); | ||
const { Worker } = require('worker_threads'); | ||
const { once } = require('events'); | ||
const helper = require('../common/report'); | ||
|
||
async function basic() { | ||
// Test that the report includes basic information about Worker threads. | ||
|
||
const w = new Worker(` | ||
const { parentPort } = require('worker_threads'); | ||
parentPort.once('message', () => { | ||
/* Wait for message to stop the Worker */ | ||
}); | ||
`, { eval: true }); | ||
|
||
await once(w, 'online'); | ||
|
||
const report = process.report.getReport(); | ||
helper.validateContent(report); | ||
assert.strictEqual(report.workers.length, 1); | ||
helper.validateContent(report.workers[0]); | ||
|
||
w.postMessage({}); | ||
|
||
await once(w, 'exit'); | ||
} | ||
|
||
async function interruptingJS() { | ||
// Test that the report also works when Worker threads are busy in JS land. | ||
|
||
const w = new Worker('while (true);', { eval: true }); | ||
|
||
await once(w, 'online'); | ||
|
||
const report = process.report.getReport(); | ||
helper.validateContent(report); | ||
assert.strictEqual(report.workers.length, 1); | ||
helper.validateContent(report.workers[0]); | ||
|
||
await w.terminate(); | ||
} | ||
|
||
(async function() { | ||
await basic(); | ||
await interruptingJS(); | ||
})().then(common.mustCall()); |