File tree 2 files changed +9
-2
lines changed
jest-environment-node/src
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,9 @@ export default class NodeEnvironment implements JestEnvironment<Timer> {
216
216
}
217
217
218
218
if ( this . context ) {
219
+ // source-map-support keeps memory leftovers in `Error.prepareStackTrace`
220
+ runInContext ( "Error.prepareStackTrace = () => '';" , this . context ) ;
221
+
219
222
// remove any leftover listeners that may hold references to sizable memory
220
223
this . context . process . removeAllListeners ( ) ;
221
224
const cluster = runInContext (
Original file line number Diff line number Diff line change @@ -312,8 +312,12 @@ async function runTestInternal(
312
312
sendMessageToJest ,
313
313
) ;
314
314
} catch ( error : any ) {
315
- // Access stack before uninstalling sourcemaps
316
- error . stack ;
315
+ // Access all stacks before uninstalling sourcemaps
316
+ let e = error ;
317
+ while ( typeof e === 'object' && 'stack' in e ) {
318
+ e . stack ;
319
+ e = e ?. cause ?? { } ;
320
+ }
317
321
318
322
throw error ;
319
323
} finally {
You can’t perform that action at this time.
0 commit comments