mirror of
https://github.com/anomalyco/opentui.git
synced 2026-09-19 01:26:03 +08:00
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.
This commit is contained in:
@@ -545,6 +545,22 @@
|
|||||||
|
|
||||||
"@opentui/core": ["@opentui/core@workspace:packages/core"],
|
"@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/examples": ["@opentui/examples@workspace:packages/examples"],
|
||||||
|
|
||||||
"@opentui/keymap": ["@opentui/keymap@workspace:packages/keymap"],
|
"@opentui/keymap": ["@opentui/keymap@workspace:packages/keymap"],
|
||||||
|
|||||||
@@ -195,11 +195,11 @@ function createNodeWorkerConstructor(node: NodeWorkerThreadsModule): PlatformWor
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.worker.off("message", this.handleMessage)
|
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) => {
|
const termination = this.worker.terminate().catch((error: unknown) => {
|
||||||
this.terminationPromise = undefined
|
this.terminationPromise = undefined
|
||||||
this.worker.on("message", this.handleMessage)
|
this.worker.on("message", this.handleMessage)
|
||||||
this.worker.on("error", this.handleError)
|
|
||||||
throw error
|
throw error
|
||||||
})
|
})
|
||||||
this.terminationPromise = termination
|
this.terminationPromise = termination
|
||||||
|
|||||||
Reference in New Issue
Block a user