File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
packages/rspack-test-tools/src/helper Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -105,10 +105,24 @@ if (process.env.DEBUG_INFO) {
105105 it = addDebugInfo ( it ) ;
106106}
107107
108+ const uncaughtExceptionListenersLength =
109+ process . listeners ( "uncaughtException" ) . length ;
110+ const unhandledRejectionListenersLength =
111+ process . listeners ( "unhandledRejection" ) . length ;
112+
108113// cspell:word wabt
109114// Workaround for a memory leak in wabt
110115// It leaks an Error object on construction
111116// so it leaks the whole stack trace
112117require ( "wast-loader" ) ;
113- process . removeAllListeners ( "uncaughtException" ) ;
114- process . removeAllListeners ( "unhandledRejection" ) ;
118+
119+ // remove the last uncaughtException / unhandledRejection listener added by wast-loader
120+ const listeners = process . listeners ( "uncaughtException" ) ;
121+ if ( listeners . length > uncaughtExceptionListenersLength ) {
122+ process . off ( "uncaughtException" , listeners [ listeners . length - 1 ] ) ;
123+ }
124+
125+ const listeners1 = process . listeners ( "unhandledRejection" ) ;
126+ if ( listeners1 . length > unhandledRejectionListenersLength ) {
127+ process . off ( "unhandledRejection" , listeners1 [ listeners1 . length - 1 ] ) ;
128+ }
You can’t perform that action at this time.
0 commit comments