test: stabilize BlueBubbles catchup parallelism

This commit is contained in:
Peter Steinberger
2026-04-20 16:40:40 +01:00
parent 17bac9e22d
commit 254417a344
2 changed files with 11 additions and 6 deletions

View File

@@ -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<void>((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<void>((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<void>((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

View File

@@ -17,7 +17,6 @@ export function createExtensionBlueBubblesVitestConfig(
{
dir: "extensions",
env,
isolate: true,
name: "extension-bluebubbles",
passWithNoTests: true,
setupFiles: ["test/setup.extensions.ts"],