From f0d10f85a8752111a94ff91ae88b575ab635d042 Mon Sep 17 00:00:00 2001 From: marco-ippolito Date: Sat, 16 Dec 2023 14:09:39 +0100 Subject: [PATCH] doc: runtime deprecate flag --trace-atomics-wait --- doc/api/deprecations.md | 9 +++++++-- src/node.cc | 4 ++++ test/parallel/test-trace-atomic-deprecation.js | 14 ++++++++++++++ test/parallel/test-trace-atomics-wait.js | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 test/parallel/test-trace-atomic-deprecation.js diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 1e7ff6f682347b..fb830914ceb99a 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -3313,6 +3313,9 @@ Values other than `undefined`, `null`, integer numbers, and integer strings -Type: Documentation-only +Type: Runtime -The [`--trace-atomics-wait`][] flag is deprecated. +The [`--trace-atomics-wait`][] flag is deprecated because +it uses the V8 hook `SetAtomicsWaitCallback`, +that will be removed in a future V8 release. ### DEP0166: Double slashes in imports and exports targets diff --git a/src/node.cc b/src/node.cc index deaed9ec3d74a9..cec88c4f4ecd84 100644 --- a/src/node.cc +++ b/src/node.cc @@ -258,6 +258,10 @@ void Environment::InitializeDiagnostics() { if (options_->trace_uncaught) isolate_->SetCaptureStackTraceForUncaughtExceptions(true); if (options_->trace_atomics_wait) { + ProcessEmitDeprecationWarning( + Environment::GetCurrent(isolate_), + "The flag --trace-atomics-wait is deprecated.", + "DEP0165"); isolate_->SetAtomicsWaitCallback(AtomicsWaitCallback, this); AddCleanupHook([](void* data) { Environment* env = static_cast(data); diff --git a/test/parallel/test-trace-atomic-deprecation.js b/test/parallel/test-trace-atomic-deprecation.js new file mode 100644 index 00000000000000..10434c417518fd --- /dev/null +++ b/test/parallel/test-trace-atomic-deprecation.js @@ -0,0 +1,14 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const { test } = require('node:test'); + +test('should emit deprecation warning DEP0165', async () => { + await common.spawnPromisified(process.execPath, ['--trace-atomics-wait', '-e', '{}']) + .then(common.mustCall(({ code, stdout, stderr }) => { + assert.strictEqual(code, 0); + assert.strictEqual(stdout, ''); + assert.match(stderr, /\[DEP0165\] DeprecationWarning:/); + })); +}); diff --git a/test/parallel/test-trace-atomics-wait.js b/test/parallel/test-trace-atomics-wait.js index 232c06be3032e6..6449a2be2b47e0 100644 --- a/test/parallel/test-trace-atomics-wait.js +++ b/test/parallel/test-trace-atomics-wait.js @@ -25,7 +25,7 @@ if (process.argv[2] === 'child') { const proc = child_process.spawnSync( process.execPath, - [ '--trace-atomics-wait', __filename, 'child' ], + [ '--disable-warning=DEP0165', '--trace-atomics-wait', __filename, 'child' ], { encoding: 'utf8', stdio: [ 'inherit', 'inherit', 'pipe' ] }); if (proc.status !== 0) console.log(proc);