Skip to content

Commit bd62ae1

Browse files
fix(server): a pull request GitHub cannot find pauses its event subscription
GitHubRest reports a 404 as GitHubApiNotFoundError, which skipped the per-pull-request pause and retried the subscription on every watch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 7e50071 commit bd62ae1

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

‎packages/source-control-github/src/server/gitHubPullRequestEvents.test.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as TestClock from "effect/testing/TestClock";
88
import { HttpClient, HttpClientResponse } from "effect/http";
99

1010
import * as GitHubPullRequestEvents from "./gitHubPullRequestEvents.ts";
11-
import { GitHubApiResponseError } from "./GitHubRequestPolicy.ts";
11+
import { GitHubApiNotFoundError, GitHubApiResponseError } from "./GitHubRequestPolicy.ts";
1212
import * as GitHubRest from "./GitHubRest.ts";
1313

1414
const target = { host: "github.com", repository: "pingdotgg/t3code", number: 15 };
@@ -17,7 +17,9 @@ const sse = (...frames: ReadonlyArray<readonly [string, string]>) =>
1717
frames.map(([event, data]) => `event: ${event}\ndata: ${data}\n\n`).join("");
1818

1919
function fakeRest(
20-
subscribe: (count: number) => Effect.Effect<string, GitHubApiResponseError>,
20+
subscribe: (
21+
count: number,
22+
) => Effect.Effect<string, GitHubApiResponseError | GitHubApiNotFoundError>,
2123
signedIn = true,
2224
) {
2325
const posts: Array<unknown> = [];
@@ -177,5 +179,17 @@ it.effect("leaves users without the app sign-in, other hosts, and refusals to po
177179
yield* TestClock.adjust("61 minutes");
178180
assert.equal(yield* Stream.runCount(events(target)), 0);
179181
assert.equal(refused.posts.length, 2);
182+
183+
const missing = fakeRest(() =>
184+
Effect.fail(
185+
new GitHubApiNotFoundError({ host: "github.com", operation: "subscribePullRequestEvents" }),
186+
),
187+
);
188+
const missingEvents = yield* eventsOf(missing.rest, httpClient);
189+
assert.equal(yield* Stream.runCount(missingEvents(target)), 0);
190+
assert.equal(yield* Stream.runCount(missingEvents(target)), 0);
191+
assert.equal(missing.posts.length, 1, "a pull request it cannot see is not asked again");
192+
assert.equal(yield* Stream.runCount(missingEvents({ ...target, number: 16 })), 0);
193+
assert.equal(missing.posts.length, 2, "other pull requests on the host still subscribe");
180194
}),
181195
);

‎packages/source-control-github/src/server/gitHubPullRequestEvents.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ export const make = Effect.gen(function* () {
9090
.pipe(
9191
Effect.asSome,
9292
Effect.catchTags({
93+
GitHubApiNotFoundError: () =>
94+
pause(resourceUrl, REFUSED_PAUSE).pipe(Effect.as(Option.none())),
9395
GitHubApiResponseError: (error) =>
9496
(error.status === 403
9597
? pause(input.host, REFUSED_PAUSE)
96-
: error.status === 404
97-
? pause(resourceUrl, REFUSED_PAUSE)
98-
: error.status === 422
99-
? pause(input.host, LIMIT_PAUSE)
100-
: Effect.void
98+
: error.status === 422
99+
? pause(input.host, LIMIT_PAUSE)
100+
: Effect.void
101101
).pipe(Effect.as(Option.none())),
102102
}),
103103
Effect.catch((error) =>

0 commit comments

Comments
 (0)