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

Memory allocation error #113

Closed
kierangraham opened this issue Jun 18, 2020 · 14 comments
Closed

Memory allocation error #113

kierangraham opened this issue Jun 18, 2020 · 14 comments
Labels

Comments

@kierangraham
Copy link

kierangraham commented Jun 18, 2020

When running Camaro using jest --watch, eventually a memory allocation error occurs after it runs for a few minutes.

Here's the example output:

 FAIL src/test.spec.ts
  ● Failing test

    RangeError: WebAssembly.Memory(): could not allocate memory

      at ../node_modules/camaro/dist/camaro.js:16:416
      at ../node_modules/camaro/worker.js:12:26
      at Object.<anonymous> (../node_modules/camaro/worker.js:10:15)

  • Camaro version: "6.0.2"
@tuananh
Copy link
Owner

tuananh commented Jun 19, 2020

@kierangraham do you have a minimal reproducible code that I can try?

@tuananh tuananh added the bug label Jun 19, 2020
@kierangraham
Copy link
Author

I'll try to find a minimum sample that triggers this and post it; until then here is some further info on the error:

Jest has detected the following 3 open handles potentially keeping Jest from exiting:

  ●  Piscina

      at new EventEmitterReferencingAsyncResource (../node_modules/eventemitter-asyncresource/src/index.ts:23:5)
      at new EventEmitterAsyncResource (../node_modules/eventemitter-asyncresource/src/index.ts:46:7)
      at new Piscina (../node_modules/piscina/src/index.ts:827:5)
      at Object.<anonymous> (../node_modules/camaro/index.js:4:14)


  ●  WORKER

      at ThreadPool._addNewWorker (../node_modules/piscina/src/index.ts:520:20)
      at ThreadPool._ensureMinimumWorkers (../node_modules/piscina/src/index.ts:514:12)
      at new ThreadPool (../node_modules/piscina/src/index.ts:508:10)
      at new Piscina (../node_modules/piscina/src/index.ts:876:18)
      at Object.<anonymous> (../node_modules/camaro/index.js:4:14)


  ●  MESSAGEPORT

      at ThreadPool._addNewWorker (../node_modules/piscina/src/index.ts:528:30)
      at ThreadPool._ensureMinimumWorkers (../node_modules/piscina/src/index.ts:514:12)
      at new ThreadPool (../node_modules/piscina/src/index.ts:508:10)
      at new Piscina (../node_modules/piscina/src/index.ts:876:18)
      at Object.<anonymous> (../node_modules/camaro/index.js:4:14)

@addaleax
Copy link

@tuananh I’ll try to take a look. The “3 open handles” warning doesn’t seem to be helpful here, though – none of these handles should be refed, i.e. none of them should keep the process running by itself.

@addaleax
Copy link

Hm yeah, there’s nothing here that sticks out to me. A reproduction would definitely be helpful. Knowing the Node.js version may or may not also be relevant?

@kierangraham
Copy link
Author

@tuananh I've managed to put together a sample project where you can reproduce the error. You can find the repo here: https://github.com/kierangraham/camaro-memory-error

Let me know if there's anything I can try to help out with!

@addaleax
Copy link

@kierangraham Thanks for the reproduction!

I think the problem here is that the camaro module is re-loaded multiple times for a single process, which each create a new worker pool. This is not really a problem outside of testing, because in “the real world”, processes don’t generally re-load modules.

I’m not sure what the best way forward here is, tbh. /cc @jasnell

@tuananh
Copy link
Owner

tuananh commented Jun 24, 2020

@kierangraham i'm closing this as I honestly don't know what to do here either.

@tuananh tuananh closed this as completed Jun 24, 2020
@tuananh tuananh added wontfix and removed bug labels Jun 24, 2020
@jasnell
Copy link

jasnell commented Jun 24, 2020

Hey @tuananh ... My schedule is pretty crazy this week but I've got this issue open and a todo to take a look at it next week to see if something can be figured out. I'll need to take some time to go through your specific set up in detail.

@kierangraham
Copy link
Author

Does anyone know of any pointers to shut down the worker pool correctly? Even when not in watch mode I see errors that something has prevented Jest from shutting down correctly when using detectOpenHandles. Any insights appreciated on how the worker pool could be released!

@liltoto
Copy link

liltoto commented Nov 2, 2020

WebAssembly.Memory(): could not allocate memory
Node version 12.x.x I had the same issue and found out it was a bug in V8. Upgrading to version 14.15.0 solved this problem.

@eduardomourar
Copy link

eduardomourar commented Nov 25, 2020

I can confirm that jest worked best with Piscina (and worker threads in general) by using nodejs v14+ and jest circus runner.

@tuananh
Copy link
Owner

tuananh commented Nov 25, 2020 via email

@jermainemercado
Copy link

Hi @kierangraham, did you ever figure this out? Running into the same issue on Node 16x LTS.

@kierangraham
Copy link
Author

kierangraham commented Dec 22, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants