-
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.
worker: remove unnecessary Worker.parent_port_ tracking
Worker.parent_port_ can be released before the exit event of Worker. The parent_port_ is not owned by `node::worker::Worker`, thus the reference to it is not always valid, and accessing it at exit crashes the process. As the Worker.parent_port_ is only used in the memory info tracking, it can be safely removed.
- Loading branch information
1 parent
5a3de82
commit 425642e
Showing
3 changed files
with
24 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const { getHeapSnapshot } = require('v8'); | ||
const { isMainThread, Worker } = require('worker_threads'); | ||
|
||
// Checks taking heap snapshot at the exit event listener of Worker doesn't | ||
// crash the process. | ||
// Regression for https://github.com/nodejs/node/issues/43122. | ||
if (isMainThread) { | ||
const worker = new Worker(__filename); | ||
|
||
worker.once('exit', common.mustCall(code => { | ||
assert.strictEqual(code, 0); | ||
getHeapSnapshot().pipe(process.stdout); | ||
})); | ||
} |