fix(e2b): harden remote teardown transactions

This commit is contained in:
Tianyi Cui
2026-07-29 07:03:04 +08:00
parent 62df6d0c09
commit ec0310ca1b
19 changed files with 712 additions and 135 deletions
+7 -1
View File
@@ -66,6 +66,7 @@ export class E2BOutputReader implements SubprocessOutputReader {
private chunks: Buffer[] = []
private retainedBytes = 0
private totalBytes = 0
private spillValid = true
/**
* Create a bounded reader over one remote spill path.
@@ -84,6 +85,11 @@ export class E2BOutputReader implements SubprocessOutputReader {
return this.totalBytes
}
/** Stop advertising a remote spill whose writer did not reach clean EOF. */
invalidateSpill(): void {
this.spillValid = false
}
/**
* Append one byte-faithful decoded transport event.
* @param bytes - Raw command bytes recovered from the ASCII SDK transport.
@@ -120,7 +126,7 @@ export class E2BOutputReader implements SubprocessOutputReader {
text: retained.subarray(start).toString('utf8'),
nextOffset: this.totalBytes,
lossy,
...(lossy && this.maxSpillBytes !== undefined && this.totalBytes <= this.maxSpillBytes
...(lossy && this.spillValid && this.maxSpillBytes !== undefined && this.totalBytes <= this.maxSpillBytes
? { spillPath: this.spillPath }
: {}),
}