Skip to content

Commit bfb6428

Browse files
roblourensCopilot
andcommitted
fix: increase macrotask flush rounds for WebKit async disposal
The TextModelResolverService.destroyReferencedObject has a multi-level async chain that needs multiple macrotask yields to complete in WebKit. Use 3 rounds of microtask + setTimeout(0) flushing instead of 1. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c33200c commit bfb6428

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/vs/workbench/contrib/chat/test/browser/widget/chatWidgetDisposal.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,13 @@ suite('ChatWidget Disposal', function () {
296296
async function flushMicrotasks() {
297297
// Flush microtask queue multiple rounds to allow nested async
298298
// chains to settle (e.g. TextModelResolverService.destroyReferencedObject).
299-
// Mix in a macrotask (setTimeout 0) for platforms where chained
299+
// Mix in macrotask yields (setTimeout 0) for platforms where chained
300300
// awaits schedule through the macrotask queue (WebKit browser).
301-
for (let i = 0; i < 20; i++) {
302-
await new Promise<void>(r => queueMicrotask(r));
303-
}
304-
await new Promise<void>(r => setTimeout(r, 0));
305-
for (let i = 0; i < 20; i++) {
306-
await new Promise<void>(r => queueMicrotask(r));
301+
for (let round = 0; round < 3; round++) {
302+
for (let i = 0; i < 20; i++) {
303+
await new Promise<void>(r => queueMicrotask(r));
304+
}
305+
await new Promise<void>(r => setTimeout(r, 0));
307306
}
308307
}
309308

0 commit comments

Comments
 (0)