fix(runtime): close portable backend boundary gaps

This commit is contained in:
Tianyi Cui
2026-07-29 19:40:39 +08:00
parent c1d550de58
commit 124fc6a611
7 changed files with 59 additions and 14 deletions

View File

@@ -59,9 +59,10 @@ export class LocalSubprocessService extends SubprocessService {
pending.push(handle.done.catch(() => {}).then(() => handle.waitForExit()))
}
for (const terminal of this.terminals) {
pending.push(terminal.terminate().then(() => { this.terminals.delete(terminal) }))
pending.push(terminal.terminate())
}
this.live.clear()
this.terminals.clear()
const outcomes = [
...await Promise.allSettled(pending),
...await Promise.allSettled([rm(this.runtimeRoot, { recursive: true, force: true })]),

View File

@@ -113,7 +113,7 @@ describe('LocalSubprocessService', () => {
expect(terminals.size).toBe(0)
})
it('waits for every terminal cleanup, removes runtime state, and retains rejections', async () => {
it('waits for every terminal cleanup and clears single-shot teardown ownership', async () => {
const ctx = new Context()
const fiber = await ctx.plugin(LocalSubprocessService)
const service = ctx.subprocess
@@ -154,7 +154,7 @@ describe('LocalSubprocessService', () => {
expect(disposed).toBe(false)
finishCleanup()
await disposing
expect(terminals).toEqual(new Set([failedTerminal, secondFailedTerminal]))
expect(terminals.size).toBe(0)
await expect(stat(runtimeRoot)).rejects.toMatchObject({ code: 'ENOENT' })
expect(disposalErrors).toHaveLength(1)
expect(disposalErrors[0]).toMatchObject({