GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): PR sync backs off links on hosts it cannot read (#36901) · pingdotgg/t3code@ea05ea5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src
    • git
      • GitManager.ts
    • orchestration-v2
      • PullRequestSyncReactor.test.ts
      • PullRequestSyncReactor.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/git/GitManager.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/git/GitManager.ts
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import * as PubSub from "effect/PubSub";
1818
import * as Ref from "effect/Ref";
1919
import * as Schema from "effect/Schema";
2020
import * as Scope from "effect/Scope";
21+
import * as Semaphore from "effect/Semaphore";
2122
import * as Stream from "effect/Stream";
2223
import {
2324
GitActionProgressEvent,
@@ -189,6 +190,9 @@ const PR_LOOKUP_FAILURE_MAX_TTL = Duration.minutes(15);
189190
const PR_LOOKUP_CACHE_CAPACITY = 2_048;
190191
const PR_LOOKUP_GIT_STATE_TTL = Duration.minutes(5);
191192
const SETTLED_PR_LOOKUP_RECHECK_INTERVAL = Duration.minutes(15);
193+
// Shared by every background caller (backfill, settlement, cleanup), so startup discovery
194+
// cannot fill the git and forge process slots that foreground work also needs.
195+
const BRANCH_PR_LOOKUP_CONCURRENCY = 4;
192196
const PR_THREAD_CONTEXT_BYTES = 16_000;
193197
const PR_THREAD_COMMAND_OUTPUT_CHARS = 2_000;
194198
const isSourceControlProviderError = Schema.is(SourceControlProviderError);
@@ -2579,6 +2583,7 @@ export const make = Effect.gen(function* () {
25792583
prLookupGitStateByKey.set(entryKey, { readAtMs, value });
25802584
return value;
25812585
});
2586+
const branchPrLookups = yield* Semaphore.make(BRANCH_PR_LOOKUP_CONCURRENCY);
25822587
const settledPrLookupByBranchKey = new Map<
25832588
string,
25842589
{ readonly url: string; readonly fingerprint: string; readonly confirmedAtMs: number }
@@ -2879,7 +2884,7 @@ export const make = Effect.gen(function* () {
28792884
});
28802885
}
28812886
return confirmed;
2882-
});
2887+
}, branchPrLookups.withPermits(1));
28832888

28842889
const checkedOutPullRequest: GitManager["Service"]["checkedOutPullRequest"] = Effect.fn(
28852890
"checkedOutPullRequest",
Collapse file

‎apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts
+41-1Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ProjectId,
99
ProviderInstanceId,
1010
PullRequestOperationError,
11+
PullRequestUnavailableError,
1112
RunId,
1213
ThreadId,
1314
TurnItemId,
@@ -180,7 +181,7 @@ interface HarnessOptions {
180181
readonly snapshot: TestShellSnapshot;
181182
readonly summary?: (
182183
input: PullRequestRef,
183-
) => Effect.Effect<PullRequestSummary, PullRequestOperationError>;
184+
) => Effect.Effect<PullRequestSummary, PullRequestService.PullRequestError>;
184185
readonly stack?: (
185186
input: PullRequestRef,
186187
) => Effect.Effect<PullRequestStack | null, PullRequestOperationError>;
@@ -1674,6 +1675,45 @@ describe("PullRequestSyncReactor", () => {
16741675
}),
16751676
);
16761677

1678+
it.effect("stops reading a pull request on a host it cannot browse each sweep", () =>
1679+
Effect.gen(function* () {
1680+
yield* TestClock.setTime(Date.parse(NOW));
1681+
const fixture = yield* makeHarness({
1682+
snapshot: makeSnapshot([
1683+
makeThread("unsupported", { pullRequests: [makeLink(9, { state: "open" })] }),
1684+
makeThread("fine", { pullRequests: [makeLink(8, { state: "open" })] }),
1685+
]),
1686+
summary: (input) =>
1687+
input.number === 9
1688+
? Effect.fail(new PullRequestUnavailableError({ reason: "provider-unsupported" }))
1689+
: Effect.succeed(makeSummary(input)),
1690+
});
1691+
const unsupportedReads = Ref.get(fixture.summaryCalls).pipe(
1692+
Effect.map((calls) => calls.filter((call) => call.number === 9).length),
1693+
);
1694+
yield* Effect.gen(function* () {
1695+
const reactor = yield* startAndSweep(fixture);
1696+
for (let index = 0; index < 5; index += 1) yield* sweepAgain(fixture, reactor);
1697+
const afterSweeps = yield* unsupportedReads;
1698+
1699+
// A refresh another link asks for must not re-read the unsupported one as well.
1700+
yield* reactor.requestSync(makeLink(9));
1701+
yield* Queue.take(fixture.snapshotReads);
1702+
yield* reactor.drain;
1703+
const afterItsRefresh = yield* unsupportedReads;
1704+
for (let index = 0; index < 3; index += 1) {
1705+
yield* reactor.requestSync(makeLink(8));
1706+
yield* Queue.take(fixture.snapshotReads);
1707+
yield* reactor.drain;
1708+
}
1709+
assert.deepStrictEqual(
1710+
{ afterSweeps, afterItsRefresh, afterOtherRefreshes: yield* unsupportedReads },
1711+
{ afterSweeps: 1, afterItsRefresh: 2, afterOtherRefreshes: 2 },
1712+
);
1713+
}).pipe(Effect.provide(fixture.layer));
1714+
}),
1715+
);
1716+
16771717
it.effect(
16781718
"holds missing links through sibling and link updates but honors a reader refresh",
16791719
() =>
Collapse file

‎apps/server/src/orchestration-v2/PullRequestSyncReactor.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/PullRequestSyncReactor.ts
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ export const make = Effect.gen(function* () {
366366
// linking dozens of pull requests) is read together and shares the summary batches.
367367
let requestedSweepQueued = false;
368368
const retryStacks = new Set<string>();
369-
// Group keys the host answered not-found for; they are read on the slow cadence until found.
369+
// Group keys the host answered not-found for, or this server cannot read (no CLI, signed out,
370+
// unsupported host); they are read on the slow cadence until a read succeeds.
370371
const missing = new Set<string>();
371372
// Pause per project and host because credentials are project-specific; leave paused PRs due until reset.
372373
const pausedUntil = new Map<string, number>();
@@ -510,9 +511,10 @@ export const make = Effect.gen(function* () {
510511
if (invalidated) yield* pullRequests.invalidate({ reference: ref });
511512
const summary = yield* pullRequests.summary(ref, { recoverTransientFailure: false }).pipe(
512513
Effect.tapError((error) =>
513-
error.reason === "not-found"
514+
error.reason === "not-found" || error._tag === "PullRequestUnavailableError"
514515
? Effect.sync(() => {
515-
// Not-found is a host answer: it consumes the refresh and starts the backoff.
516+
// Not-found, or a host this server cannot read, won't change by asking again
517+
// next sweep: it consumes the refresh and starts the backoff.
516518
missing.add(key);
517519
lastSyncedAt.set(key, nowMs);
518520
requested.delete(key);

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.