diff --git a/extensions/bluebubbles/src/catchup.test.ts b/extensions/bluebubbles/src/catchup.test.ts index 7e4a265dea7..4116fcbb513 100644 --- a/extensions/bluebubbles/src/catchup.test.ts +++ b/extensions/bluebubbles/src/catchup.test.ts @@ -115,16 +115,21 @@ describe("runBlueBubblesCatchup", () => { let fetchCount = 0; let processCount = 0; - let resolveFetch: (() => void) | null = null; + let releaseFetch: (() => void) | undefined; + let fetchStartedResolve: (() => void) | undefined; + const fetchStarted = new Promise((resolve) => { + fetchStartedResolve = resolve; + }); const call1 = runBlueBubblesCatchup(makeTarget(), { now: () => now, fetchMessages: async () => { fetchCount++; + fetchStartedResolve?.(); // Block until we fire the second call, so we can verify it // coalesces rather than starting a new run. await new Promise((resolve) => { - resolveFetch = resolve; + releaseFetch = resolve; }); return { resolved: true, @@ -136,8 +141,9 @@ describe("runBlueBubblesCatchup", () => { }, }); - // Wait a tick for call1 to enter fetchMessages, then fire call2. - await new Promise((resolve) => setTimeout(resolve, 5)); + // Wait for call1 to enter fetchMessages, then fire call2. A fixed + // sleep is load-sensitive and can leave call1 permanently blocked. + await fetchStarted; const call2 = runBlueBubblesCatchup(makeTarget(), { now: () => now, fetchMessages: async () => { @@ -149,7 +155,7 @@ describe("runBlueBubblesCatchup", () => { }, }); - resolveFetch!(); + releaseFetch?.(); const [r1, r2] = await Promise.all([call1, call2]); expect(fetchCount).toBe(1); // second call coalesced, didn't re-fetch diff --git a/test/vitest/vitest.extension-bluebubbles.config.ts b/test/vitest/vitest.extension-bluebubbles.config.ts index 2816e4b5369..f9931ee732f 100644 --- a/test/vitest/vitest.extension-bluebubbles.config.ts +++ b/test/vitest/vitest.extension-bluebubbles.config.ts @@ -17,7 +17,6 @@ export function createExtensionBlueBubblesVitestConfig( { dir: "extensions", env, - isolate: true, name: "extension-bluebubbles", passWithNoTests: true, setupFiles: ["test/setup.extensions.ts"],