@@ -13,6 +13,7 @@ const fsync = require('fs')
13
13
const net = require('net')
14
14
const zlib = require('zlib')
15
15
const { Profile } = require('pprof-format')
16
+ const satisfies = require('semifies')
16
17
17
18
const DEFAULT_PROFILE_TYPES = ['wall', 'space']
18
19
if (process.platform !== 'win32') {
@@ -329,15 +330,23 @@ describe('profiler', () => {
329
330
// with recomputed busyCycleTimeNs, but let's give ourselves more leeway.
330
331
this.retries(9)
331
332
const procStart = BigInt(Date.now() * 1000000)
332
- const proc = fork(path.join(cwd, 'profiler/codehotspots.js'), {
333
- cwd,
334
- env: {
335
- DD_PROFILING_EXPORTERS: 'file',
336
- DD_PROFILING_ENABLED: 1,
337
- BUSY_CYCLE_TIME: (busyCycleTimeNs | 0).toString(),
338
- DD_TRACE_AGENT_PORT: agent.port
333
+ const env = {
334
+ DD_PROFILING_EXPORTERS: 'file',
335
+ DD_PROFILING_ENABLED: 1,
336
+ BUSY_CYCLE_TIME: (busyCycleTimeNs | 0).toString(),
337
+ DD_TRACE_AGENT_PORT: agent.port
338
+ }
339
+ // With Node 23 or later, test the profiler with async context frame use.
340
+ let execArgv = []
341
+ if (satisfies(process.versions.node, '>=23.0.0')) {
342
+ env.DD_PROFILING_USE_ASYNC_CONTEXT_FRAME = 1
343
+ if (!satisfies(process.versions.node, '>=24.0.0')) {
344
+ // For Node 23, use the experimental command line flag for Node to enable
345
+ // async context frame. Node 24 has it enabled by default.
346
+ execArgv = ['--experimental-async-context-frame']
339
347
}
340
- })
348
+ }
349
+ const proc = fork(path.join(cwd, 'profiler/codehotspots.js'), { cwd, env, execArgv })
341
350
342
351
await processExitPromise(proc, timeout)
343
352
const procEnd = BigInt(Date.now() * 1000000)
0 commit comments