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(core): skip in-flight retries on warm SharedCache refreshes by hearnadam · Pull Request #66676 · anomalyco/opencode

Conversation

@hearnadam

@hearnadam hearnadam commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Follows #66673 (independent; branched off dev so it can be reviewed and merged in either order).

Observed Problem

From Cloudflare Workers Observability on opencode-console-api-production (24h ending 2026-11-26 ~20:56 UTC):

  • GET /console/api/v2/config receives ~105.7M requests/day (~1,223 req/s).
  • During PlanetScale stalls (e.g., 2026-11-25 07:40–07:55 UTC: 118 500s; 11:35:30–11:36:00 UTC: 260 500s; 11:48:00–11:48:30 UTC: 100 500s), Worker requests hang up to ~30s (wallTimeMs ~30,023–30,137ms) before returning 500.

Diagnosis

packages/core/src/shared-cache.ts:61-63 retries every transient failure (TimeoutError, TransportError, 408/429/5xx) 3 times with unjittered Schedule.exponential("1 second") — even when the cache already holds a valid cached value that will be kept on failure. Because fetchConfig / fetchList time out at 5s (packages/core/src/plugin/provider/opencode.ts:621,653), every polling client sends 4 overlapping requests in ~27s during a database stall while earlier timed-out requests are still held server-side.

Changes

  • packages/core/src/shared-cache.ts:
    • Skip in-flight retries on warm refreshes (when entry.last?.exit is already a success), keeping the cached value until the next interval.
    • On cold loads (no cached value yet), reduce retries from 3 unjittered to 2 jittered (Schedule.exponential("1 second").pipe(Schedule.jittered)).
  • packages/core/src/plugin/provider/opencode.ts: update the timeout comment on fetchConfig to reflect cold-load-only retries.
  • Tests: updated retry-count expectations in packages/core/test/shared-cache.test.ts and packages/core/test/plugin/provider-opencode.test.ts, and added a test verifying warm-refresh stalls do not amplify requests.

No feature flag is added (per AGENTS.md, fixes do not require a flag).

Expected Impact

  • Cuts stall retry amplification on warm refreshes by 4x (4 overlapping requests/27s -> 1 request per client), combining with fix(core): poll Console config every 5 minutes with jitter #66673 for a ~20x reduction in load during database stalls.

Verification

  • bun run script/test.ts test/shared-cache.test.ts test/plugin/provider-opencode.test.ts test/plugin/provider-azure.test.ts test/plugin/provider-digitalocean.test.ts test/plugin/provider-github-copilot.test.ts in packages/core: 126 pass, 0 fail.
  • bun run script/test.ts test/shared-cache.test.ts test/plugin/provider-opencode.test.ts --rerun-each 10 --randomize in packages/core: 620 pass, 0 fail.
  • Verified the new stall test goes red when the warm-refresh guard is removed.
  • bun typecheck and bun run typecheck:tsc in packages/core: passed.
  • Pre-push bun run check across all packages: passed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added the contributor label Nov 26, 2026
This was referenced Nov 26, 2026
fix(core): back off repeated SharedCache failures and honor Retry-After #66678
Draft
fix(core): poll Console config every 5 minutes with jitter #66673
Merged
@hearnadam
fix(core): skip in-flight retries on warm SharedCache refreshes
5b74c1b
@hearnadam
hearnadam force-pushed the shared-cache-retries branch from f1eaffd to 5b74c1b Compare November 27, 2026 03:32
@hearnadam
hearnadam marked this pull request as ready for review November 27, 2026 04:36
opencodejr[bot]
opencodejr Bot reviewed Nov 27, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found no problems that should block a merge. On a warm refresh, a stalled Console now gets one request per client instead of four, and the last good value is kept. Cold loads still retry, now twice with jitter.

How I checked: the new stall test fails against the base shared-cache.ts (4 requests where 2 are expected) and passes with this change. The shared-cache and provider tests pass, including 10 runs in random order (630/630), so the jittered retry delays don't make the tests flaky. tsc passes.

Failures are still cached, and the last good value is kept as before. A failed refresh is stamped with the time it started, so a stalled upstream gets one try per interval. The other users of the shared cache (Azure, DigitalOcean, GitHub Copilot, Modal and the provider refresh code) still work.

Public API: unchanged (internal SharedCache retry behaviour only).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@hearnadam
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — 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.