@@ -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' ) {
@@ -332,15 +333,23 @@ describe('profiler', () => {
332
333
// with recomputed busyCycleTimeNs, but let's give ourselves more leeway.
333
334
this . retries ( 9 )
334
335
const procStart = BigInt ( Date . now ( ) * 1000000 )
335
- const proc = fork ( path . join ( cwd , 'profiler/codehotspots.js' ) , {
336
- cwd,
337
- env : {
338
- DD_PROFILING_EXPORTERS : 'file' ,
339
- DD_PROFILING_ENABLED : 1 ,
340
- BUSY_CYCLE_TIME : ( busyCycleTimeNs | 0 ) . toString ( ) ,
341
- DD_TRACE_AGENT_PORT : agent . port
336
+ const env = {
337
+ DD_PROFILING_EXPORTERS : 'file' ,
338
+ DD_PROFILING_ENABLED : 1 ,
339
+ BUSY_CYCLE_TIME : ( busyCycleTimeNs | 0 ) . toString ( ) ,
340
+ DD_TRACE_AGENT_PORT : agent . port
341
+ }
342
+ // With Node 23 or later, test the profiler with async context frame use.
343
+ const execArgv = [ ]
344
+ if ( satisfies ( process . versions . node , '>=23.0.0' ) ) {
345
+ env . DD_PROFILING_USE_ASYNC_CONTEXT_FRAME = 1
346
+ if ( ! satisfies ( process . versions . node , '>=24.0.0' ) ) {
347
+ // For Node 23, use the experimental command line flag for Node to enable
348
+ // async context frame. Node 24 has it enabled by default.
349
+ execArgv . push ( '--experimental-async-context-frame' )
342
350
}
343
- } )
351
+ }
352
+ const proc = fork ( path . join ( cwd , 'profiler/codehotspots.js' ) , { cwd, env, execArgv } )
344
353
345
354
await processExitPromise ( proc , timeout )
346
355
const procEnd = BigInt ( Date . now ( ) * 1000000 )
0 commit comments