-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
squash! tracing: forbid tracing modifications from worker threads
- Loading branch information
Showing
4 changed files
with
44 additions
and
2 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,11 @@ | ||
// Flags: --experimental-worker | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const { Worker } = require('worker_threads'); | ||
|
||
new Worker("require('trace_events')", { eval: true }) | ||
.on('error', common.expectsError({ | ||
code: 'ERR_TRACE_EVENTS_UNAVAILABLE', | ||
type: Error | ||
})); |
28 changes: 28 additions & 0 deletions
28
test/parallel/test-trace-events-dynamic-enable-workers-disabled.js
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,28 @@ | ||
// Flags: --experimental-worker | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const { Worker } = require('worker_threads'); | ||
|
||
common.skipIfInspectorDisabled(); | ||
|
||
if (!process.env.HAS_STARTED_WORKER) { | ||
process.env.HAS_STARTED_WORKER = 1; | ||
new Worker(__filename); | ||
return; | ||
} | ||
|
||
const assert = require('assert'); | ||
const { Session } = require('inspector'); | ||
|
||
const session = new Session(); | ||
session.connect(); | ||
session.post('NodeTracing.start', { | ||
traceConfig: { includedCategories: ['node.perf'] } | ||
}, common.mustCall((err) => { | ||
assert.deepStrictEqual(err, { | ||
code: -32000, | ||
message: | ||
'Tracing properties can only be changed through main thread sessions' | ||
}); | ||
})); |