Skip to content

Commit 19c1fb7

Browse files
committed
Test the async context frame with Node 23 and later
1 parent 2e1d37e commit 19c1fb7

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

integration-tests/profiler/profiler.spec.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const fsync = require('fs')
1313
const net = require('net')
1414
const zlib = require('zlib')
1515
const { Profile } = require('pprof-format')
16+
const satisfies = require('semifies')
1617

1718
const DEFAULT_PROFILE_TYPES = ['wall', 'space']
1819
if (process.platform !== 'win32') {
@@ -332,15 +333,23 @@ describe('profiler', () => {
332333
// with recomputed busyCycleTimeNs, but let's give ourselves more leeway.
333334
this.retries(9)
334335
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')
342350
}
343-
})
351+
}
352+
const proc = fork(path.join(cwd, 'profiler/codehotspots.js'), { cwd, env, execArgv })
344353

345354
await processExitPromise(proc, timeout)
346355
const procEnd = BigInt(Date.now() * 1000000)

0 commit comments

Comments
 (0)