From f015a73f3ee5861863f78514820bef9c5151923d Mon Sep 17 00:00:00 2001 From: Simon Klee Date: Wed, 16 Sep 2026 10:20:18 +0200 Subject: [PATCH] core: keep worker error listener on termination (#1508) A worker can emit an error while termination is pending. Keep its listener attached so Node does not turn that failure into an uncaught exception. --- bun.lock | 16 ++++++++++++++++ packages/core/src/platform/worker.ts | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bun.lock b/bun.lock index 46a086ff5..e19408ca0 100644 --- a/bun.lock +++ b/bun.lock @@ -545,6 +545,22 @@ "@opentui/core": ["@opentui/core@workspace:packages/core"], + "@opentui/core-darwin-arm64": ["@opentui/core-darwin-arm64@0.5.11", "", { "os": "darwin", "cpu": "arm64" }, "sha512-DRXY5ioq+n1ZNAMAcaFaBunr0cmi2gqucjbTW7lgFp8t9uN3fNZnLTDOqkCTQtT2XhrU4GXqySaPSQ4qFG/EAQ=="], + + "@opentui/core-darwin-x64": ["@opentui/core-darwin-x64@0.5.11", "", { "os": "darwin", "cpu": "x64" }, "sha512-yP/8GliJDiJNm8YYJKvgWuy6xyCEd8d4GwBVOIzCFOI7ZIbGP8GOTvmwIjRW4Paw20pTttWMWyRoQiCvOXvH2g=="], + + "@opentui/core-linux-arm64": ["@opentui/core-linux-arm64@0.5.11", "", { "os": "linux", "cpu": "arm64" }, "sha512-zBIsRFHlLUYFNhapRSNt9dz4mC8gZ4Wxcfy3A+2AwqsgCipcr2FkIuAXYqN08q+IvqFX7DfqgIFGWDNedHTPUg=="], + + "@opentui/core-linux-arm64-musl": ["@opentui/core-linux-arm64-musl@0.5.11", "", { "os": "linux", "cpu": "arm64" }, "sha512-x+xeR2LYibvIi/qQetRjJR008sFRve60QuDcO8ItxUwzFeKTDzl5CEiZpBXfm5I4FhRNuyuj0TSPIFadMvrjFQ=="], + + "@opentui/core-linux-x64": ["@opentui/core-linux-x64@0.5.11", "", { "os": "linux", "cpu": "x64" }, "sha512-pSOXqOADrv+zINOgR3FDFA9zVRaim3zl8/yhtO+X9rEJ6f34z3gDund0Gf88hNJSMpZK5xWtipEVm28RY5VF8w=="], + + "@opentui/core-linux-x64-musl": ["@opentui/core-linux-x64-musl@0.5.11", "", { "os": "linux", "cpu": "x64" }, "sha512-MyqOnSs8pTYG2xmFr1xt6xZIuHu2Xu4pkle9my9JdE+WClmusHf0YN9Eas6jQLAq5XUi34r22wMeK0juk93zyw=="], + + "@opentui/core-win32-arm64": ["@opentui/core-win32-arm64@0.5.11", "", { "os": "win32", "cpu": "arm64" }, "sha512-MGGRXIDJ//HyaqC5ndSr7/CUl+ICdYEAMcjbA00UWsthh4ZO/rYhPkyqOaTn5ck6+G4ca3/+M76J+jImMYTjNg=="], + + "@opentui/core-win32-x64": ["@opentui/core-win32-x64@0.5.11", "", { "os": "win32", "cpu": "x64" }, "sha512-sMEGX9rhiPd1gBa190jzj5uIdzKCMImxHmr22hJLxIRWqejxWvqGnRBkW68wT8NfMViDiMtZWavgWL7GgmYCAQ=="], + "@opentui/examples": ["@opentui/examples@workspace:packages/examples"], "@opentui/keymap": ["@opentui/keymap@workspace:packages/keymap"], diff --git a/packages/core/src/platform/worker.ts b/packages/core/src/platform/worker.ts index 4aec08d5e..f32232109 100644 --- a/packages/core/src/platform/worker.ts +++ b/packages/core/src/platform/worker.ts @@ -195,11 +195,11 @@ function createNodeWorkerConstructor(node: NodeWorkerThreadsModule): PlatformWor } this.worker.off("message", this.handleMessage) - this.worker.off("error", this.handleError) + // Keep the error listener so a worker that fails during terminate() cannot + // become an uncaught exception (Node emits 'error' with no listeners). const termination = this.worker.terminate().catch((error: unknown) => { this.terminationPromise = undefined this.worker.on("message", this.handleMessage) - this.worker.on("error", this.handleError) throw error }) this.terminationPromise = termination