fix(e2b): fence teardown and terminal publication

This commit is contained in:
Tianyi Cui
2026-07-29 07:42:25 +08:00
parent e9bef2967d
commit 022841027f
9 changed files with 237 additions and 22 deletions
+3 -1
View File
@@ -213,6 +213,7 @@ export class E2BSubprocessHandle implements SubprocessHandle {
private invalidHandleQuiescent = false
private provisionalHandleQuiescent = false
private terminationStarted = false
private terminationSucceeded = false
private terminationAttempt: Promise<void> | undefined
private terminationFailure: Error | undefined
private terminationSignal: NodeJS.Signals | null = null
@@ -264,13 +265,14 @@ export class E2BSubprocessHandle implements SubprocessHandle {
/** @inheritdoc */
terminate(): void {
if (this.terminationAttempt !== undefined) return
if (this.terminationSucceeded || this.terminationAttempt !== undefined) return
this.terminationStarted = true
this.terminationFailure = undefined
const attempt = this.terminateRemote()
this.terminationAttempt = attempt
void attempt.then(
() => {
this.terminationSucceeded = true
this.terminationAttempt = undefined
},
(error: unknown) => {