SalesforceCommerceCloud / raml-toolkit

BSD 3-Clause "New" or "Revised" License
28 stars 7 forks source link

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed #227

Open newsgrep opened 2 months ago

newsgrep commented 2 months ago

I useed Linux native with npm 10.8.3 node 22.8.0. And also Docker with node:18-alpine and node:20-alpine and I have > 14GB RAM free. I always get the same error, any hints how to processed?:

$ sudo npm install -g @commerce-apps/raml-toolkit@0.5.12; node --trace-deprecation /usr/local/bin/raml-toolkit diff --log-level=debug /tmp/old.raml /tmp/new -f console

npm warn deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated rimraf@2.7.1: Rimraf versions prior to v4 are no longer supported
npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn deprecated @oclif/command@1.8.36: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated @oclif/help@1.0.15: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated @oclif/command@1.8.4: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated @oclif/errors@1.3.6: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated @oclif/errors@1.3.6: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated @oclif/errors@1.3.5: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated fstream@1.0.12: This package is no longer supported.
npm warn deprecated @oclif/config@1.18.1: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated @oclif/config@1.18.2: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated @oclif/parser@3.8.17: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated @oclif/config@1.18.16: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated sparqlee@1.10.0: Sparqlee has been moved to @comunica/expression-evaluator

changed 478 packages in 8s

30 packages are looking for funding
  run `npm fund` for details
(node:14358) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
    at node:punycode:3:9
    at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:399:7)
    at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:338:10)
    at loadBuiltinModule (node:internal/modules/helpers:108:7)
    at Module._load (node:internal/modules/cjs/loader:1099:17)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)
    at Object.<anonymous> (/usr/local/lib/node_modules/@commerce-apps/raml-toolkit/node_modules/whatwg-url/lib/url-state-machine.js:2:18)
Finding differences between flattened JSON-LD of /tmp/old.raml and /tmp/new.raml
Added plugin to include node ID in the node delta: addNodeInfo,collectChildren,trivial,dates,texts,objects,arrays

<--- Last few GCs --->

[14358:0x35958000]    19360 ms: Mark-Compact 2002.3 (2095.4) -> 2000.4 (2095.7) MB, pooled: 1 MB, 246.40 / 0.00 ms  (average mu = 0.075, current mu = 0.005) allocation failure; scavenge might not succeed
[14358:0x35958000]    19597 ms: Mark-Compact 2001.0 (2095.9) -> 2000.6 (2095.4) MB, pooled: 2 MB, 237.03 / 0.00 ms  (average mu = 0.039, current mu = 0.001) allocation failure; scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0xe35ec2 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
 2: 0x124f9c0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 3: 0x124fc97 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 4: 0x147f4d5  [node]
 5: 0x147f503  [node]
 6: 0x14985ba  [node]
 7: 0x149b788  [node]
 8: 0x1e340b1  [node]
joeluong-sfcc commented 3 weeks ago

Hey @newsgrep, thanks for creating this issue. Does this issue happen outside a docker environment? When you say you have 14 GB of RAM free, does that mean for your machine or the memory you've allocated for your docker container? I'm not sure what the issue is but here's a few things you can try:

  1. clear cache: npm cache clean --force
  2. use a different version of node
  3. Increase maximum memory for docker with the --memory flag
  4. Increase memory for node with the --max-old-space-size flag: https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes

Let me know if this doesn't resolve the issue, I can create a ticket in our backlog for this work.