Not enough memory while testing a Node.js appplication

nodejs

#1

Hey,

I’m facing this error while testing my Node.js application with Jest@0.20.3 on CircleCI 2.0 in a custom Docker image:

    ENOMEM: not enough memory, read
    at Error (native)
  
  at Object.fs.readSync (fs.js:732:19)
  at tryReadSync (fs.js:487:20)
  at Object.fs.readFileSync (fs.js:527:19)
  at Object.<anonymous> (modules/service-jobs/node_modules/aws-sdk/clients/all.js:38:20)

I’m not really sure what’s going as our tests are passing locally.

Any lead?

Thanks,
Aymeric


#2

How much RAM do your tests use locally?
Were you testing on 1.0? Did you need extra resources there?


#3

Just tested locally, they use ~1GB tops.

We are new customers and directly jumped in CircleCI 2.0.

Here is a link to a failing build: https://circleci.com/gh/Brigad/brigad-back-end/279 (not all the builds are failing).


#4

Seems like your _JAVA_OPTIONS aren’t being respected. Maybe you need a different key, like JAVA_OPTS?


#5

Java should not be an issue here, I included this env var to limit the amount of memory allocated by https://github.com/atlassian/localstack (seen it here https://stackoverflow.com/a/11578259/1071486).

I tried this solution after the first memory errors occurred on CircleCI.

Let me remove it :thumbsup:


#6

I do think Java is part of the issue here. You’re running it in the background at the same time you’re trying to run JS tests, so you run out of memory.


#7

Actually LocalStack will spawn several processes, I do agree this might cause an issue.

I will try to spawn LocalStack as a separate Docker container :ok_hand:

Do you confirm it will be automatically linked with the main container and that it will not share the same memory limit?


#8

What do you mean by “linked”?

Correct, though; a separate container wouldn’t share the same 4GB RAM.


#9

1/ I meant: any port exposed by the container will be available in the main container?

2/ Ok great for the ram :ok_hand:


#10

That won’t be the case when it’s in the remote environment. That’s currently a limitation of the base docker executor.

Maybe you need to further limit the memory and keep it in the same container.


#11

I was thinking of the Multiple images features, the ports should be available on localhost right?


#12

Oh, sorry! Yes, those images share localhost. Any ports defined with EXPOSE will be automatically exposed.


#13

Ok, so I managed to reduce the quantity of ram used by LocalStack by specifying the services I want to use. This seemed to have solve the issue :ok_hand:


#14

Follow up: The errors kept popping, I had to split LocalStack to a separate container (leveraging the multiple images feature).

Now I would like to run containers from a non-primary image (ideally setup_remote_docker), is this something I can do? If not do you have any solution to offer?


#15

The only viable solution to that problem is more RAM, which you can contact cs@circleci.com to enquire about. As a fair warning, it’s only available to paid accounts.


More RAM request
#16

Thanks @rohara!


#17

I fixed jest memory issues by running it single threaded with -w 1. The container does have only 1 thread anyway.


#18

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.