fix(#2791): await session.abort() in all subagent completion/cancel paths
Fire-and-forget session.abort() calls during subagent completion left dangling promises that raced with parent session teardown. In Bun on WSL2/Linux, this triggered a StringImplShape assertion (SIGABRT) as WebKit GC collected string data still referenced by the inflight request. Fix: await session.abort() in all four completion/error paths: - startTask promptAsync error handler (launch path) - resume promptAsync error handler (resume path) - cancelTask (explicit cancel path) - tryCompleteTask (normal completion path) Also marks the two .catch() error callbacks as async so the await is valid. Test: update session.deleted cascade test to flush two microtask rounds since cancelTask now awaits abort before cleanupPendingByParent.
This commit is contained in:
@@ -3728,6 +3728,9 @@ describe("BackgroundManager.handleEvent - session.deleted cascade", () => {
|
||||
properties: { info: { id: parentSessionID } },
|
||||
})
|
||||
|
||||
// Flush twice: cancelTask now awaits session.abort() before cleanupPendingByParent,
|
||||
// so we need additional microtask ticks to let the cascade complete fully.
|
||||
await flushBackgroundNotifications()
|
||||
await flushBackgroundNotifications()
|
||||
|
||||
// then
|
||||
|
||||
Reference in New Issue
Block a user