Giter Club home page Giter Club logo

Comments (5)

leebyron avatar leebyron commented on May 3, 2024 2

@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.

ThisIsMissEm avatar ThisIsMissEm commented on May 3, 2024 1

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.

rturk avatar rturk commented on May 3, 2024

Hi all any updates on this? I'm having similar issues

from dataloader.

ThisIsMissEm avatar ThisIsMissEm commented on May 3, 2024

See also #62

from dataloader.

lucasbento avatar lucasbento commented on May 3, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.