From fee711055d590c356a1cf7de5ac722ef0991be5a Mon Sep 17 00:00:00 2001 From: eladcon Date: Wed, 1 May 2024 19:52:11 +0300 Subject: [PATCH] fix: can't use `setUncaughtExceptionCaptureCallback` with `domain` module (#6391) Fixes #6390 ## Checklist - [ ] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [ ] Description explains motivation and solution - [ ] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*. --- libs/wingcompiler/preflight.shim.cjs | 2 +- libs/wingsdk/src/shared/sandbox.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 }); });