Comments (5)
@lucasbento - can you possibly replace your Mongo instance with some sort of mock so you can present the issue? I can't reproduce it, and we have tests that cover the clear functions that continue to pass.
My best guess from the information you shared is that you're using userLoader.clear(id.toString());
while using userLoader.load(id);
- if id
is not already a string these will result in different keys, so clear()
will be attempting to clear the wrong key.
I'm more confused by clearAll()
not working. It's implementation simply only calls clear()
on the underlying cache Map
instance. If you're not providing a custom implementation of Map
(check your polyfills?) then perhaps something else is wrong with your application?
from dataloader.
I'd take a guess that the issue you're seeing here is because you're sharing the dataloader instance between all your requests – instead, you should only use dataloader for a single requests' lifetime – otherwise you'll end up sharing data between requests.
The "workers", if running in a separate process, have a different instance of that dataloader.
That is, dataloader works entirely in memory: if you go to a different machine or different process, then you've a completely new dataloader instance. If your process restarts, same deal.
That is, dataloader really isn't much more than something like this:
function createFetcher(fn) {
var cache = {}
return {
fetch: function fetch(id) {
if (!cache[id]) {
cache[id] = fn(id);
}
return cache[id];
},
clear: function clear(id) {
delete cache[id];
}
}
(Sure, it uses process.nextTick to do batching, but the code above is meant to represent and show how it is in-memory)
from dataloader.
Hi all any updates on this? I'm having similar issues
from dataloader.
See also #62
from dataloader.
@leebyron: I'm gonna try to check what you just said, @ThisIsMissEm also has a good point, thank you both for answering.
I'm focusing on other projects right now so I don't really have enough time to work on this issue, I'm gonna try the suggestions as soon as I can, I'll close this issue for now and open again if needed.
Thank you!
from dataloader.
Related Issues (20)
- Move CI to GitHub Actions
- Setup publish token for CI
- Change default branch `master` to `main` HOT 1
- Setup Renovate Bot to keep dependencies up to date HOT 3
- [QUESTION] Why aren't keys being de-duplicated even when the cache is disabled? HOT 6
- ✨ [REQUEST]: Add examples for cacheKeyFn and cacheMap HOT 2
- [REQUEST]: How to pass auth headers to dataloader HOT 4
- [QUESTION] README.md doesn't show on npmjs.com HOT 2
- CacheMap.get calls should await the promised value HOT 1
- [QUESTION] Release changes? HOT 9
- [QUESTION] name is now required in options? HOT 4
- [BUG] Readme is missing from NPM HOT 2
- [BUG] `this` context not available in typescript definitions
- [BUG] Use caution with `jest.useFakeTimers()` HOT 1
- [REQUEST] support vercel edge functions by default HOT 4
- Ever considered the use of `queueMicrotask`? HOT 1
- Coalescing multiple load() calls HOT 3
- [REQUEST] Unify the way `load` and `loadMany` handle errors
- -
- [REQUEST] Add batch grouping
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dataloader.