pnpm: Heap limit Allocation failed - JavaScript heap out of memory

pnpm version: 7.2.1

I’m trying to compile https://github.com/ledgerhq/ledger-live and when I do I’m getting this error:

ledger-live-desktop:build-ci: <--- JS stacktrace --->
ledger-live-desktop:build-ci: 
ledger-live-desktop:build-ci: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
ledger-live-desktop:build-ci:  1: 0xb09980 node::Abort() [node]
ledger-live-desktop:build-ci:  2: 0xa1c235 node::FatalError(char const*, char const*) [node]
ledger-live-desktop:build-ci:  3: 0xcf784e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
ledger-live-desktop:build-ci:  4: 0xcf7bc7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
ledger-live-desktop:build-ci:  5: 0xeaf465  [node]
ledger-live-desktop:build-ci:  6: 0xebf12d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
ledger-live-desktop:build-ci:  7: 0xec1e2e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
ledger-live-desktop:build-ci:  8: 0xe8336a v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
ledger-live-desktop:build-ci:  9: 0x11fc0b6 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
ledger-live-desktop:build-ci: 10: 0x15f0b19  [node]
ledger-live-desktop:build-ci:  ELIFECYCLE  Command failed with exit code 1.
ledger-live-desktop:build-ci: [07:18:59] Compiling assets [failed]
ledger-live-desktop:build-ci: [07:18:59] → Command failed with exit code 1: pnpm run build
ledger-live-desktop:build-ci: [07:18:59] Build [failed]
ledger-live-desktop:build-ci: [07:18:59] → Command failed with exit code 1: pnpm run build
ledger-live-desktop:build-ci: Error: Command failed with exit code 1: pnpm run build
ledger-live-desktop:build-ci:     at makeError (/home/user/Work/WETER/ledger-live/node_modules/.pnpm/execa@4.1.0/node_modules/execa/lib/error.js:59:11)
ledger-live-desktop:build-ci:     at handlePromise (/home/user/Work/WETER/ledger-live/node_modules/.pnpm/execa@4.1.0/node_modules/execa/index.js:114:26)
ledger-live-desktop:build-ci:     at processTicksAndRejections (node:internal/process/task_queues:96:5)
ledger-live-desktop:build-ci:     at async Task.task (/home/user/Work/WETER/ledger-live/apps/ledger-live-desktop/tools/dist/index.js:70:7) {
ledger-live-desktop:build-ci:   shortMessage: 'Command failed with exit code 1: pnpm run build',
ledger-live-desktop:build-ci:   command: 'pnpm run build',
ledger-live-desktop:build-ci:   exitCode: 1,
ledger-live-desktop:build-ci:   signal: undefined,
ledger-live-desktop:build-ci:   signalDescription: undefined,
ledger-live-desktop:build-ci:   stdout: undefined,
ledger-live-desktop:build-ci:   stderr: undefined,
ledger-live-desktop:build-ci:   failed: true,
ledger-live-desktop:build-ci:   timedOut: false,
ledger-live-desktop:build-ci:   isCanceled: false,
ledger-live-desktop:build-ci:   killed: false,
ledger-live-desktop:build-ci:   context: [Object: null prototype] {}
ledger-live-desktop:build-ci: }
ledger-live-desktop:build-ci:  ELIFECYCLE  Command failed with exit code 255.
ledger-live-desktop:build-ci: Error: command finished with error: command (apps/ledger-live-desktop) pnpm run build-ci exited (1)
command (apps/ledger-live-desktop) pnpm run build-ci exited (1)

Code to reproduce the issue:

git clone git@github.com:LedgerHQ/ledger-live.git
cd ledger-live
pnpm i
pnpm build:lld

Additional information:

This issue might be related: https://github.com/pnpm/pnpm/issues/2339

  • node -v prints: v16.14.2 (nvm --lts)
  • Linux, Debian testing VM with 10GB of RAM (VirtualBox with windows 10 host)

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 19 (8 by maintainers)

Commits related to this issue

Most upvoted comments

any updates ? facing the same issue with the pnpm version 6 and 7

The original issue was about pnpm run. Don’t post here issues related to out-of-memory errors while using other commands. I have fixed an OOM error in the install command recently. But it is not related to this issue.

Create new issues.

@yarinsa Can you confirm that you have a WORKDIR in your Dockerfile?

@BirkhoffLee I reproduced your case, and it indeed reached heap limit when run in Docker. But the problem is, you should not add -r option as you’re not in a monorepo, pnpm install --offline --prod will do it for you instantly. @zkochan I did not checked the code, but I guess when pnpm-workspace.yaml is not present, adding-r options to install lead pnpm dive into the virtual store. If that is the case, probably it’d be better to default to ‘!node_modules/**’ when scanning for workspace packages.

same error from pnpm list

looks like infinite recursion in a circular dependency graph

cd $(mktemp -d)
git clone --depth 1 https://github.com/TanStack/query
cd query
pnpm install
pnpm list -r --depth 999
# FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory