Repository navigation
Batch GitHub GraphQL queries to avoid API timeout on large changesets - #1925
TooTallNate wants to merge 4 commits into
Conversation
When there are many changesets, the single GraphQL query built by
DataLoader can become too large for GitHub's API to validate, causing
"Timeout on validation of query" errors.
This change:
- Splits the DataLoader batch into sub-batches (default 100 items each)
to keep individual queries within GitHub's limits
- Adds a cacheKeyFn to DataLoader so its deduplication cache actually
works (previously broken due to object reference equality in Map keys)
- Adds progress logging when multiple batches are needed
- Makes batch size configurable via config.json ("batchSize" option)
or CHANGESET_GITHUB_BATCH_SIZE env var
🦋 Changeset detectedLatest commit: 4e33a50 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Bundles a patched version of @changesets/changelog-github that batches GitHub GraphQL API requests to avoid "Timeout on validation of query" errors when there are many changesets. Upstream PR: changesets/changesets#1925
There was a problem hiding this comment.
Pull request overview
This PR addresses GitHub GraphQL "Timeout on validation of query" failures for very large changesets by batching GraphQL lookups and improving request deduplication via DataLoader caching.
Changes:
- Split a single large DataLoader GraphQL request into sequential batches (default size 100) and add progress logging for multi-batch runs.
- Fix DataLoader cache deduplication by adding
cacheKeyFn, reducing redundant GitHub lookups. - Add configurable batch size wiring from
@changesets/changelog-githubinto@changesets/get-github-info.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| packages/get-github-info/src/index.ts | Implements batching, cache keying, and exposes setBatchSize/clearCache. |
| packages/get-github-info/src/index.test.ts | Updates tests to import clearCache and clears cache in the custom GraphQL URL test. |
| packages/changelog-github/src/index.ts | Passes options.batchSize into setBatchSize for both release line generators. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1925 +/- ##
==========================================
+ Coverage 83.37% 83.40% +0.03%
==========================================
Files 56 56
Lines 2466 2507 +41
Branches 742 759 +17
==========================================
+ Hits 2056 2091 +35
- Misses 404 410 +6
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Add input validation to setBatchSize (throws RangeError on invalid)
- Use Number() coercion + null check for options.batchSize in changelog-github
- Switch progress logging from console.log to console.error (stderr)
- Move clearCache() to afterEach for proper test isolation
- Fix pre-existing typo in comment ('use' -> 'us')
- Add changeset file
The changelog-github test mock uses `typeof import(...)` so it must include all exports from get-github-info, including the new setBatchSize and clearCache functions.
- Test that setBatchSize rejects invalid values (0, negative, float, NaN, Infinity) - Test that two distinct commits with batchSize=1 triggers two separate GraphQL requests, exercising the batching code path - Fix GITHUB_GRAPHQL_URL restore in custom-URL test (was setting env var to string 'undefined' instead of deleting it)
… generator (#26) The Release job intermittently failed in 'Create Version PR' with: Failed to parse data from GitHub Invalid response body while trying to fetch https://api.github.com/graphql: Premature close That GraphQL call is made by @changesets/changelog-github (via @changesets/get-github-info), which does a single fetch with no retry, so one dropped connection aborts the whole release. The packages are effectively unmaintained (see changesets/changesets#1925). Replace them with scripts/changelog-github.mjs, a self-contained ESM changelog generator that produces byte-for-byte identical output but adds: - retry with exponential backoff + jitter on transient failures (premature close, resets, timeouts, 5xx, 429) - GraphQL request batching + correct cache-key dedup (the fix from changesets/changesets#1925, which was never merged upstream) - loud failure after exhausting retries — no silent degraded changelog, so real outages surface instead of shipping an inconsistent CHANGELOG Verified against the live GitHub API: 'changeset version' output is identical to the upstream plugin. Adds tests/changelog-github.test.mjs (stubbed fetch; format match, retry, fail-loud, no-retry-on-auth).
|
We had fixed this in #2121 by using dataloader's builtin batch size handling: I believe this should address your issue if you use the latest beta versions. However it looks like we didn't handle the Sorry to have missed the PR. |
Summary
When there are many changesets (e.g. 600+), the single GraphQL query built by DataLoader becomes too large for GitHub's API to validate, resulting in
"Timeout on validation of query"errors.Changes
Batched GraphQL requests (
@changesets/get-github-info)fetchBatch()helperFixed DataLoader cache deduplication (
@changesets/get-github-info)cacheKeyFnto the DataLoader so its result cache actually worksMapsemantics), so identical requests for the same commit/PR were never deduplicatedConfigurable batch size (
@changesets/changelog-github).changeset/config.json:{ "changelog": ["@changesets/changelog-github", { "repo": "org/repo", "batchSize": 50 }] }CHANGESET_GITHUB_BATCH_SIZE=50