fix(server): keep VCS refresh responsive during slow remote lookups #13052
ClosedTamoMaes(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/13052/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/vcs/VcsStatusBroadcaster.ts line 537Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -490,2 +494,21 @@490494 }),491495 );496+ if (options?.waitForRemote !== false) return yield* refresh;497+498+ const cached = yield* getCachedStatus(cwd);499+ const local = yield* refreshLocalStatusCore(cwd);500+ // The UI already subscribes to status updates. A slow fetch or PR lookup501+ // must not hold its refresh request open or queue duplicate remote reads.502+ yield* Effect.uninterruptibleMask((restore) =>503+ Effect.gen(function* () {504+ if (pendingStatusRefreshes.has(cwd)) return;505+ pendingStatusRefreshes.add(cwd);506+ yield* restore(refresh).pipe(507+ Effect.ignoreCause({ log: true }),508+ Effect.onExit(() => Effect.sync(() => pendingStatusRefreshes.delete(cwd))),509+ Effect.forkIn(broadcasterScope),510+ );511+ }),512+ );513+ const remote =514+ cached?.local?.value.refName === local.refName ? (cached?.remote?.value ?? null) : null;apps/server/src/vcs/VcsStatusBroadcaster.ts line 493OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -489 +493 @@489493 return yield* updateCachedStatus(cwd, local, remote, { publish: true });
- apps/server/src/vcs/VcsStatusBroadcaster.ts lines 536 to 538Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -491 +495,21 @@491495 );496+ if (options?.waitForRemote !== false) return yield* refresh;497+498+ const cached = yield* getCachedStatus(cwd);499+ const local = yield* refreshLocalStatusCore(cwd);500+ // The UI already subscribes to status updates. A slow fetch or PR lookup501+ // must not hold its refresh request open or queue duplicate remote reads.502+ yield* Effect.uninterruptibleMask((restore) =>503+ Effect.gen(function* () {504+ if (pendingStatusRefreshes.has(cwd)) return;505+ pendingStatusRefreshes.add(cwd);506+ yield* restore(refresh).pipe(507+ Effect.ignoreCause({ log: true }),508+ Effect.onExit(() => Effect.sync(() => pendingStatusRefreshes.delete(cwd))),509+ Effect.forkIn(broadcasterScope),510+ );511+ }),512+ );513+ const remote =514+ cached?.local?.value.refName === local.refName ? (cached?.remote?.value ?? null) : null;515+ return mergeGitStatusParts(local, remote);
juliusmarminge added labelsmacroscope-review
maria-rcks closed this
Sign in to join this conversation.
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. To continue using code reviews, add credits to your account and enable them for code reviews in your settings.