@@ -59,23 +59,29 @@ if (NODE_MAJOR >= 24 && !process.env.OPTIONS_OVERRIDE) {
59
59
const childProcess = require ( 'child_process' )
60
60
const { exec, fork } = childProcess
61
61
62
- function addAsyncContextFrame ( fn , thisArg , args ) {
62
+ childProcess . exec = function ( ... args ) {
63
63
const opts = args [ 1 ]
64
64
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'
69
70
}
70
71
}
71
- return fn . apply ( thisArg , args )
72
+ return exec . apply ( this , args )
72
73
}
73
74
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 )
80
86
}
81
87
}
0 commit comments