Visitar URL original
fix: preserve replacement cache entries after batch failure by Claire-ovo · Pull Request #404 · graphql/dataloader · GitHub
Skip to content

fix: preserve replacement cache entries after batch failure - #404

Open
Claire-ovo wants to merge 1 commit into
graphql:mainfrom
Claire-ovo:fix/preserve-replacement-cache
Open

Claire-ovo wants to merge 1 commit into
graphql:mainfrom
Claire-ovo:fix/preserve-replacement-cache

Conversation

@Claire-ovo

Copy link
Copy Markdown

Fixes #403.

If a key is cleared and reloaded or primed while an earlier batch is pending, that batch's failure currently evicts the replacement entry. Track each queued request's promise and only clear the cache when it still contains that promise. The original rejection, normal failed-request eviction, and per-item error caching are preserved.

Adds 17 deterministic regression/control cases for pending, completed and primed replacements, normalized keys, custom cache maps, batching on/off, repeated keys across batches, disabled caching and synchronous batch exceptions. Against the original source, 14 fail and 3 pass; with this fix, the full 76-test suite passes on Node 18, 20 and 22. npm run test:ci -- --runInBand passes on Node 22 (lint, Flow, and 100% statement/branch/function/line coverage), as do the build and a built-output reproduction.

Includes a patch changeset. This changes observable cache behavior after failure; happy to adjust the release classification if needed. Related Python-port fix: syrusakbary/aiodataloader#60.

@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed batch evicts a replacement cache entry after clear/prime

1 participant