Skip to content

Commit ec6756a

Browse files
committed
fix(hot-poll): surfaces hadErrors via pushError for user visibility
1 parent cb6ce9e commit ec6756a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/app/services/poll.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ export function createHotPollCoordinator(
565565
if (myGeneration !== chainGeneration) return; // Chain destroyed during fetch
566566
if (hadErrors) {
567567
consecutiveFailures++;
568+
pushError("hot-poll", "Some status updates failed — retrying with backoff", true);
568569
} else {
569570
consecutiveFailures = 0;
570571
}

tests/services/hot-poll.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ describe("createHotPollCoordinator", () => {
593593
});
594594
});
595595

596-
it("applies exponential backoff on errors", async () => {
596+
it("applies exponential backoff on errors and surfaces via pushError", async () => {
597597
const onHotData = vi.fn();
598598
// fetchHotPRStatus uses Promise.allSettled, so graphql errors set hadErrors=true
599599
// without throwing — consecutiveFailures increments via the hadErrors path
@@ -606,13 +606,18 @@ describe("createHotPollCoordinator", () => {
606606
pullRequests: [makePullRequest({ id: 1, checkStatus: "pending", nodeId: "PR_a" })],
607607
});
608608

609+
const { pushError } = await import("../../src/app/lib/errors");
610+
(pushError as ReturnType<typeof vi.fn>).mockClear();
611+
609612
await createRoot(async (dispose) => {
610613
createHotPollCoordinator(() => 10, onHotData);
611614

612615
// First cycle at 10s — hadErrors=true, consecutiveFailures=1
613616
await vi.advanceTimersByTimeAsync(10_000);
614617
const callsAfterFirst = graphqlFn.mock.calls.length;
615618
expect(callsAfterFirst).toBe(1);
619+
// hadErrors surfaces error to user
620+
expect(pushError).toHaveBeenCalledWith("hot-poll", expect.any(String), true);
616621

617622
// Next cycle should be at 10s * 2^1 = 20s from first cycle
618623
// Advance 10s — should NOT have fired another fetch yet

0 commit comments

Comments
 (0)