Skip to content
New issue

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

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

Already on GitHub? # to your account

eslint failed with out of memory error #4363

Closed
ksilverwall opened this issue May 1, 2023 · 6 comments
Closed

eslint failed with out of memory error #4363

ksilverwall opened this issue May 1, 2023 · 6 comments
Labels

Comments

@ksilverwall
Copy link
Contributor

Description

eslint failed with out of memory error after e2e test executed.

Steps to reproduce

  1. clone this repo
  2. init node_modules with npx pnpm install
  3. execute pnpm run dev and pnpm exec cypress open for e2e test
  4. execute some e2e tests on any browser
  5. execute eslint

Screenshots

Error Log

% git commit -m "namespace rect is not filled"

> mermaid-monorepo@10.1.0 pre-commit /Users/kazuki_tsunemi/work/mermaid-package/mermaid
> lint-staged

✔ Preparing lint-staged...
❯ Running tasks for staged files...
  ❯ packages/mermaid/.lintstagedrc.mjs — 1 file
    ❯ !(docs/**/*)*.{ts,js,json,html,md,mts} — 1 file
      ✖ eslint --cache --cache-strategy content --fix [SIGABRT]
      ◼ prettier --write
    ↓ cSpell.json — no files [SKIPPED]
    ↓ **/*.jison — no files [SKIPPED]
    ↓ src/docs/** — no files [SKIPPED]
    ↓ src/docs.mts — no files [SKIPPED]
    ↓ src/(defaultConfig|config|mermaidAPI).ts — no files [SKIPPED]
↓ Skipped because of errors from tasks. [SKIPPED]
✔ Reverting to original state because of errors...
✔ Cleaning up temporary files...

✖ eslint --cache --cache-strategy content --fix:

<--- Last few GCs --->

[71148:0x7fca40040000]    31620 ms: Scavenge 4046.3 (4120.6) -> 4045.8 (4130.6) MB, 10.2 / 0.0 ms  (average mu = 0.799, current mu = 0.653) allocation failure; 
[71148:0x7fca40040000]    31650 ms: Scavenge 4052.4 (4130.6) -> 4051.2 (4131.9) MB, 9.5 / 0.0 ms  (average mu = 0.799, current mu = 0.653) allocation failure; 
[71148:0x7fca40040000]    32567 ms: Scavenge 4053.5 (4131.9) -> 4052.5 (4152.4) MB, 909.0 / 0.0 ms  (average mu = 0.799, current mu = 0.653) allocation failure; 


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10a5dbeb5 node::Abort() (.cold.1) [/Users/kazuki_tsunemi/.volta/tools/image/node/18.16.0/bin/node]
 2: 0x109051a69 node::Abort() [/Users/kazuki_tsunemi/.volta/tools/image/node/18.16.0/bin/node]
 3: 0x109051c4e node::OOMErrorHandler(char const*, bool) [/Users/kazuki_tsunemi/.volta/tools/image/node/18.16.0/bin/node]
 4: 0x1091dd653 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/kazuki_tsunemi/.volta/tools/image/node/18.16.0/bin/node]
 5: 0x1093a6305 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/kazuki_tsunemi/.volta/tools/image/node/18.16.0/bin/node]
 6: 0x1093a4ce2 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/kazuki_tsunemi/.volta/tools/image/node/18.16.0/bin/node]
 7: 0x10939701a v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/kazuki_tsunemi/.volta/tools/image/node/18.16.0/bin/node]
 8: 0x109397995 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/kazuki_tsunemi/.volta/tools/image/node/18.16.0/bin/node]
 9: 0x109379e0e v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Users/kazuki_tsunemi/.volta/tools/image/node/18.16.0/bin/node]
10: 0x1097afc6c v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/Users/kazuki_tsunemi/.volta/tools/image/node/18.16.0/bin/node]
11: 0x109ba57f9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/kazuki_tsunemi/.volta/tools/image/node/18.16.0/bin/node]
 ELIFECYCLE  Command failed with exit code 1.
husky - pre-commit hook exited with code 1 (error)

Code Sample

No response

Setup

  • Mermaid version: develop (56ec1ab)
  • Browser and Version: no browser

Additional Context

eslint may check the node_modules.
When I refresh node_modules then error is distinct temporally.

@ksilverwall ksilverwall added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels May 1, 2023
@sidharthv96 sidharthv96 added Contributor needed Good first issue! and removed Status: Triage Needs to be verified, categorized, etc labels May 17, 2023
@guypursey
Copy link
Contributor

I've also had this error. It was preventing me from contributing as the pre-commit hook would run eslint and produce this memory issue before I could commit.

I tried the 4 solutions above but didn't have any luck with them (but they might work for others).

I've found that running pnpm build before doing anything that starts eslint has helped -- eslint seems to run without hitting the memory issue then.

(I've also found that increasing the memory available to Node through export NODE_OPTIONS="_max_old_space_size=4096" can help but your memory situation may vary. This was on my laptop with 8GB RAM.)

@ilyes-ced
Copy link
Contributor

i had this problem as well my solution was

  • delete node_modules and rerun npx pnpm install

you might want to clear eslint cache as well in .eslintcache
and maybe prettier too rm ./node_modules/.cache/prettier/.prettier-cache

@ksilverwall
Copy link
Contributor Author

Is it necessary to run lint to node_modules ?
ignore this dir

@ilyes-ced
Copy link
Contributor

Is it necessary to run lint to node_modules ?
ignore this dir

i don't think the linter lints node_modules
for me deleting it and reinstalling worked just fine and this error stopped

maybe it has to do with cache or something

@sidharthv96
Copy link
Member

Fixed after update to eslint v9

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

No branches or pull requests

5 participants