Skip to content

Commit ad139f6

Browse files
committed
Revert "simpler adding --no-async-context-frame (#5717)"
This reverts commit fcf95b2.
1 parent 7ecad19 commit ad139f6

File tree

1 file changed

+18
-12
lines changed
  • packages/dd-trace/test/setup

1 file changed

+18
-12
lines changed

packages/dd-trace/test/setup/core.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,29 @@ if (NODE_MAJOR >= 24 && !process.env.OPTIONS_OVERRIDE) {
5959
const childProcess = require('child_process')
6060
const { exec, fork } = childProcess
6161

62-
function addAsyncContextFrame (fn, thisArg, args) {
62+
childProcess.exec = function (...args) {
6363
const opts = args[1]
6464
if (opts) {
65-
const env = opts.env ||= {}
66-
env.NODE_OPTIONS ||= ''
67-
if (!env.NODE_OPTIONS.includes('--no-async-context-frame')) {
68-
env.NODE_OPTIONS += ' --no-async-context-frame'
65+
if (opts?.env?.NODE_OPTIONS && !opts.env.NODE_OPTIONS.includes('--no-async-context-frame')) {
66+
opts.env.NODE_OPTIONS += ' --no-async-context-frame'
67+
} else {
68+
opts.env ||= {}
69+
opts.env.NODE_OPTIONS = '--no-async-context-frame'
6970
}
7071
}
71-
return fn.apply(thisArg, args)
72+
return exec.apply(this, args)
7273
}
7374

74-
childProcess.exec = function () {
75-
return addAsyncContextFrame(exec, this, arguments)
76-
}
77-
78-
childProcess.fork = function () {
79-
return addAsyncContextFrame(fork, this, arguments)
75+
childProcess.fork = function (...args) {
76+
const opts = args[1]
77+
if (opts) {
78+
if (opts?.env?.NODE_OPTIONS && !opts.env.NODE_OPTIONS.includes('--no-async-context-frame')) {
79+
opts.env.NODE_OPTIONS += ' --no-async-context-frame'
80+
} else {
81+
opts.env ||= {}
82+
opts.env.NODE_OPTIONS = '--no-async-context-frame'
83+
}
84+
}
85+
return fork.apply(this, args)
8086
}
8187
}

0 commit comments

Comments
 (0)