@devries-cameron20 / t3code-1 / commits / ebb3dd0b76
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(source-control-github): sign out an app sign-in GitHub refuses to refresh for the client's credentials (#39048)

Julius Marminge committed Nov 19, 2026 at 12:18 UTC ebb3dd0b76009c44373d7cc558f36efb28779a0d
2 files changed +23 -3
packages/source-control-github/src/server/GitHubAppSignIn.test.ts
+14
@@ -350,6 +350,20 @@ describe("GitHubAppSignIn", () => {
350 }).pipe(Effect.provide(layer));
351 });
352
353 + it.effect("does not ask GitHub again after it rejects the client's credentials", () => {
354 + const { layer, requests } = harness({
355 + signIns: { "github.com": session({ accessTokenExpiresAt: 0 }) },
356 + handle: () => ({ body: { error: "incorrect_client_credentials" } }),
357 + });
358 + return Effect.gen(function* () {
359 + const signIn = yield* GitHubAppSignIn.GitHubAppSignIn;
360 + yield* Effect.exit(signIn.token("github.com"));
361 + yield* Effect.exit(signIn.token("github.com"));
362 + expect(requests).toHaveLength(1);
363 + expect(yield* savedSignIns).toEqual({});
364 + }).pipe(Effect.provide(layer));
365 + });
366 +
367 it.effect("serves the still-valid token when a refresh ahead of expiry fails", () => {
368 const { layer } = harness({
369 signIns: { "github.com": session({ accessTokenExpiresAt: 3 * 60_000 }) },
packages/source-control-github/src/server/GitHubAppSignIn.ts
+9 -3
@@ -213,9 +213,15 @@ export const make = Effect.gen(function* () {
213 },
214 TokenResponse,
215 ).pipe(Effect.mapError((cause) => new GitHubAppSessionError({ host, cause })));
216 - if (response.error === "bad_refresh_token") {
217 - // Final: the user revoked the app or the session lapsed.
218 - yield* Effect.logWarning("GitHub refused the app sign-in refresh; signing out.", { host });
216 + if (
217 + response.error === "bad_refresh_token" ||
218 + response.error === "incorrect_client_credentials"
219 + ) {
220 + // Final: the user revoked the app, the session lapsed, or this server's client cannot refresh it.
221 + yield* Effect.logWarning("GitHub refused the app sign-in refresh; signing out.", {
222 + host,
223 + error: response.error,
224 + });
225 yield* replaceSession(host, session, null).pipe(Effect.ignore);
226 return Option.none<string>();
227 }