@@ -55,23 +55,29 @@ if (NODE_MAJOR >= 24 && !process.env.OPTIONS_OVERRIDE) {
55
55
const childProcess = require ( 'child_process' )
56
56
const { exec, fork } = childProcess
57
57
58
- function addAsyncContextFrame ( fn , thisArg , args ) {
58
+ childProcess . exec = function ( ... args ) {
59
59
const opts = args [ 1 ]
60
60
if ( opts ) {
61
- const env = opts . env ||= { }
62
- env . NODE_OPTIONS ||= ''
63
- if ( ! env . NODE_OPTIONS . includes ( '--no-async-context-frame' ) ) {
64
- env . NODE_OPTIONS += ' --no-async-context-frame'
61
+ if ( opts ?. env ?. NODE_OPTIONS && ! opts . env . NODE_OPTIONS . includes ( '--no-async-context-frame' ) ) {
62
+ opts . env . NODE_OPTIONS += ' --no-async-context-frame'
63
+ } else {
64
+ opts . env ||= { }
65
+ opts . env . NODE_OPTIONS = '--no-async-context-frame'
65
66
}
66
67
}
67
- return fn . apply ( thisArg , args )
68
+ return exec . apply ( this , args )
68
69
}
69
70
70
- childProcess . exec = function ( ) {
71
- return addAsyncContextFrame ( exec , this , arguments )
72
- }
73
-
74
- childProcess . fork = function ( ) {
75
- return addAsyncContextFrame ( fork , this , arguments )
71
+ childProcess . fork = function ( ...args ) {
72
+ const opts = args [ 1 ]
73
+ if ( opts ) {
74
+ if ( opts ?. env ?. NODE_OPTIONS && ! opts . env . NODE_OPTIONS . includes ( '--no-async-context-frame' ) ) {
75
+ opts . env . NODE_OPTIONS += ' --no-async-context-frame'
76
+ } else {
77
+ opts . env ||= { }
78
+ opts . env . NODE_OPTIONS = '--no-async-context-frame'
79
+ }
80
+ }
81
+ return fork . apply ( this , args )
76
82
}
77
83
}
0 commit comments