Skip to content

Commit 2025471

Browse files
committed
fix(delegation): bound handoff finalization drain
1 parent aaba859 commit 2025471

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎src/core/webview/ClineProvider.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,19 @@ export class ClineProvider
367367
private async drainProviderHandoffFinalizations(): Promise<void> {
368368
const pending = Array.from(this.providerHandoffFinalizations ?? [])
369369
if (pending.length === 0) return
370-
await Promise.allSettled(pending)
370+
let timeout: ReturnType<typeof setTimeout> | undefined
371+
const drained = await Promise.race([
372+
Promise.allSettled(pending).then(() => true),
373+
new Promise<false>((resolve) => {
374+
timeout = setTimeout(() => resolve(false), ClineProvider.PROFILE_MUTATION_DISPOSAL_DRAIN_TIMEOUT_MS)
375+
}),
376+
])
377+
if (timeout) clearTimeout(timeout)
378+
if (!drained) {
379+
this.log(
380+
`Provider disposal detached ${pending.length} still-running handoff finalization operation(s); late settlements are inert`,
381+
)
382+
}
371383
}
372384

373385
/**

0 commit comments

Comments
 (0)