diff --git a/libs/wingcompiler/preflight.shim.cjs b/libs/wingcompiler/preflight.shim.cjs index 67f05f9862f..b7c5ae1a495 100644 --- a/libs/wingcompiler/preflight.shim.cjs +++ b/libs/wingcompiler/preflight.shim.cjs @@ -6,7 +6,7 @@ /// 1. The environment variable WING_PREFLIGHT_ENTRYPOINT is a JSON string of the entrypoint to load /// 2. Runs in a child process with an IPC channel to the parent process -process.setUncaughtExceptionCaptureCallback((reason) => { +process.on("uncaughtException", (reason) => { if (reason instanceof Error) { // The Error object does not serialize well over IPC (even with 'advanced' serialization) // So we extract the properties we need to recreate most error objects diff --git a/libs/wingsdk/src/shared/sandbox.ts b/libs/wingsdk/src/shared/sandbox.ts index 5a28e780ba1..f430f963adc 100644 --- a/libs/wingsdk/src/shared/sandbox.ts +++ b/libs/wingsdk/src/shared/sandbox.ts @@ -59,7 +59,7 @@ export class Sandbox { // wrap contents with a shim that handles the communication with the parent process // we insert this shim before bundling to ensure source maps are generated correctly contents += ` -process.setUncaughtExceptionCaptureCallback((reason) => { +process.on("uncaughtException", (reason) => { process.send({ type: "reject", reason }); });