Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM resolve does not ignore calls before quibbledModules are set #116

Open
markusvoelk-zr opened this issue Nov 15, 2024 · 2 comments
Open

Comments

@markusvoelk-zr
Copy link

I think the intention of the following code snipped is to ignore resolve calls until the first module gets "quibbled":

(https://github.com/testdouble/quibble/blob/fac450e65d68a00411a7ed51fc29f19af581f95b/lib/quibble.mjs#L42C1-L44C4)

if (!quibbleLoaderState.quibbledModules) {
    return resolve()
  }

Because the quibbleLoaderState.quibbledModules is a (at least) empty Map, the (!quibbleLoaderState.quibbledModules) expression never gets true.

I got memory issues because every imported module will be cached (and quibbled).
Changing the if-clause to if (!quibbleLoaderState.quibbledModules.size) { solves the issue for me.

Is there an other reason, the .size is missing?

@rosston
Copy link
Member

rosston commented Nov 15, 2024

Does "memory issues" mean a leak and large memory usage? It feels like this could be cause of testdouble/testdouble.js#534.

@markusvoelk-zr
Copy link
Author

Yes, i think a intended memory leak (ESM loader does not provide a way to cleanup code cache).
But i think quibble quibbles too much modules because of the code mentioned here.

In my memory dumps, i see a lot of (superfluous) dev packages (sinon, chai, ...). I think it is intentional to have the prod-code in the memory dump?

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

No branches or pull requests

2 participants