Title: Chat diff-status worker re-downloads unchanged PRs instead of using conditional requests · Issue #27627 · coder/coder · GitHub
Open Graph Title: Chat diff-status worker re-downloads unchanged PRs instead of using conditional requests · Issue #27627 · coder/coder
X Title: Chat diff-status worker re-downloads unchanged PRs instead of using conditional requests · Issue #27627 · coder/coder
Description: Summary The chat diff-status worker polls open pull requests on a fixed 10s interval and re-downloads the full JSON body on every tick, even when nothing changed. The GitHub client (coderd/externalauth/gitprovider/github.go) never sends ...
Open Graph Description: Summary The chat diff-status worker polls open pull requests on a fixed 10s interval and re-downloads the full JSON body on every tick, even when nothing changed. The GitHub client (coderd/external...
X Description: Summary The chat diff-status worker polls open pull requests on a fixed 10s interval and re-downloads the full JSON body on every tick, even when nothing changed. The GitHub client (coderd/external...
Opengraph URL: https://github.com/coder/coder/issues/27627
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Chat diff-status worker re-downloads unchanged PRs instead of using conditional requests","articleBody":"## Summary\n\nThe chat diff-status worker polls open pull requests on a fixed 10s interval and re-downloads the full JSON body on every tick, even when nothing changed. The GitHub client (`coderd/externalauth/gitprovider/github.go`) never sends `If-None-Match` / ETag, so GitHub always returns a full `200 OK` instead of a cheap `304 Not Modified`.\n\n## Why it matters\n\n`304` responses don't count against GitHub's **primary rate limit**; full `200`s do. Every unchanged poll needlessly burns a user's/installation's API quota — multiplied by the number of tracked PRs and the 10s cadence. On busy instances this worker can quietly exhaust the quota that the same token needs for interactive Git and API operations, so users hit rate-limit errors and stalls elsewhere in Coder. Adopting conditional requests fixes that with no behavior change — unchanged PRs revalidate for free, and only real changes transfer a body.\n\n## Where\n\n- `coderd/x/gitsync/worker.go`: `defaultInterval = 10 * time.Second`, `defaultBatchSize = 50`.\n- Per refresh (all full `200`s today): `ResolveBranchPullRequest` → `GET /repos/{owner}/{repo}/pulls?...`; `FetchPullRequestStatus` → `GET /repos/{owner}/{repo}/pulls/{n}` and `.../pulls/{n}/reviews?per_page=100`.\n- `githubProvider.decodeJSON` sets `Accept`, `X-GitHub-Api-Version`, and a bearer token but no `If-None-Match`, and keeps no ETag cache. The worker is a long-lived singleton, so an in-process cache persists across ticks.\n\n## Proposed fix\n\nAdd a small, concurrency-safe, bounded ETag+body cache and wire it into `decodeJSON`: key on request URL + a hash of the token (never serve one token's response under another; don't retain raw tokens); send `If-None-Match` when an ETag is cached; on `304` decode the cached body; on `200` cache `{etag, body}` under a size cap. Bound by entry count and per-body size. Leave the raw-diff path (`fetchDiff`) out of scope to avoid caching large bodies.","author":{"url":"https://github.com/joshfree","@type":"Person","name":"joshfree"},"datePublished":"2026-07-29T00:45:44Z","url":"https://github.com/coder/coder/issues/27627"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ad8a76bd-c4ec-4e59-9a0d-4aa7ff966111 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D1A0:1739C:3860F6:4B3B7C:6B04B9EB |
| html-safe-nonce | d85825a473b0d0a4a72fb1db5b5129f75e82a09e30df423625b48fbb2ad039f5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMUEwOjE3MzlDOjM4NjBGNjo0QjNCN0M6NkIwNEI5RUIiLCJ2aXNpdG9yX2lkIjoiMzQyMzM2NDQ2NzQ0OTQ0NDg0MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 40f0e965453d79062407a98d90b5b4a22c87e418d52aa6232200efe763801d0b |
| hovercard-subject-tag | issue:5004241844 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/coder/27627/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4bed2dbdfbf40ed298a8af6cc88c34774fcfc1ed410d907c870766f23a83cb20/coder/coder/issues/27627 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4bed2dbdfbf40ed298a8af6cc88c34774fcfc1ed410d907c870766f23a83cb20/coder/coder/issues/27627 |
| og:image:alt | Summary The chat diff-status worker polls open pull requests on a fixed 10s interval and re-downloads the full JSON body on every tick, even when nothing changed. The GitHub client (coderd/external... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | joshfree |
| hostname | github.com |
| expected-hostname | github.com |
| None | 378bd702ac792b3550e484ad39d9a898fcd25bb52ba6962b0c9cc457c1ea71c7 |
| turbo-cache-control | no-preview |
| go-import | github.com/coder/coder git https://github.com/coder/coder.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 440752086 |
| octolytics-dimension-repository_nwo | coder/coder |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 440752086 |
| octolytics-dimension-repository_network_root_nwo | coder/coder |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b032e77f1ea437ede6c115446a0a467709b468e7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width