[BUG] Cached calls to `load()` still result in new Promise creation
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, node.js
- Ambito
- backend-api-design
Direzione di ricerca
Inizia da src/index.js intorno alla riga 92 e confronta il percorso della cache con l’affermazione della documentazione relativa alla creazione delle promise. Esamina il commit 06c403bd72abef401dd7619c8ae992f03ed6b7d3 e determina se i caricamenti ripetuti debbano riutilizzare la promise memorizzata nella cache senza modificare il comportamento del batching; il lavoro è completo quando il comportamento è coperto da test mirati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Expected Behavior
The docs state creating a new Promise and new key in the batchLoadFn for every load of the same key. When loading large datasets that can contain large amounts of duplicates this means we could call load(1) 100k times and we should get 1 total promise.
Current Behavior
The source code reveals that whether or not we use the cache, we still end up creating a new promise. https://github.com/graphql/dataloader/blob/main/src/index.js#L92 .
Possible Solution
Why not just return the cachedPromise?
Context
It looks like the change originates from https://github.com/graphql/dataloader/commit/06c403bd72abef401dd7619c8ae992f03ed6b7d3 . It's been many years, but the reasoning behind that change feels misguided maybe? As the code stands right now, isn't the value of "caching promises" entirely eliminated because we end up creating a new promise for every load call. So if 50k records all relate to the same record that means 50k promises, rather than 1. The trade-off for that loss is that we can re-use cache from an earlier call, but is that really used enough to warrant that behavior? The current code only provides value in the event we have a partially primed cache, where some objects are cached and others are not, ensuring that subsequent loads end up on the same tick. That feels like a pretty edgy-ish behavior that almost should be solved using different batch loading techniques.
- Lingua principale
- JavaScript
- Stelle
- 13.4k
- Fork
- 522
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di graphql/dataloader
-
[BUG] `maxBatchSize: NaN` is accepted and silently disables batchingForse già presa @RaphaelFakhri l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
graphql/dataloader#405 ·
-
Failed batch evicts a replacement cache entry after clear/primeForse già presa @Claire-ovo l’ha presa 11 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 57/100
graphql/dataloader#403 ·
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
graphql/dataloader#393 ·
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
graphql/dataloader#382 ·
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
graphql/dataloader#379 · 2 commenti · 5 reazioni ·
Tutte le issue di graphql/dataloader
Issue simili
-
bug needs-triage potential-regression
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
aws/aws-sdk-js-v3#8408 ·
I maintainer di solito rispondono entro 1 giorno
-
[v3] KeyBindingManager calls (Add/Remove) are not converted into a case-insensitive accelerator.KeyApertaBug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 4 giorni
-
fix(docs): align git__gh troubleshooting with its actual failure pathsForse già presa @akhil9tiet l’ha presa oggi. Apertabug docs p2
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
vercel/eve#6130 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100