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

Worker terminated due to reaching memory limit: JS heap out of memory #127

Closed
2 tasks done
olemarius opened this issue Mar 24, 2022 · 28 comments
Closed
2 tasks done
Labels
upstream Bug in a dependency

Comments

@olemarius
Copy link

Describe the bug

Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit: JS heap out of memory

image

Reproduction

current setting:

checker({
                terminal: true,
                vueTsc: true,
                typescript: false,
                eslint: {
                    lintCommand: 'eslint --format=pretty . --ext .js,.ts,.vue',
                },
                overlay:{
                    initialIsOpen: false,
                    position: 'bl'
                }
            }),

Expected behavior

no heap out of memory error, or ability to increase memory limit

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
    Memory: 11.24 GB / 31.92 GB
  Binaries:
    Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.3.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 99.0.4844.82
    Edge: Spartan (44.22000.120.0), Chromium (99.0.1150.46)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    vite-plugin-checker: ^0.4.4 => 0.4.4

Additional context

No response

Validations

  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@DannyFeliz
Copy link

I have the same issue except that I only have vueTsc: true enabled

@jzs11
Copy link

jzs11 commented Mar 24, 2022

It's a regression in 0.4.4, I have the same error. Downgraded it to resolve the problem.

F.y.i
vitejs/vite#7443

@fi3ework
Copy link
Owner

fi3ework commented Mar 25, 2022

🤔 Guess this is related to vue-tsc watch mode. I made a minimal repro without vite-plugin-checker and it seems like there's a potential memory leak. vuejs/language-tools#1106

@fi3ework fi3ework added the upstream Bug in a dependency label Mar 25, 2022
@fi3ework
Copy link
Owner

fi3ework commented Mar 25, 2022

Seems like it's fixed in vue-tsc@0.33.9. Try it out :)

@ngokevin
Copy link

ngokevin commented Mar 30, 2022

Hmm, a number of us are getting out-of-memory on 0.4.3 and we don't use Vue/vue-tsc. Any ideas?

@jzs11
Copy link

jzs11 commented Mar 30, 2022

Just an update after a few days using 0.4.4 and vue-tsc@0.33.9, most of the time is fine. However, I still experienced 2-3 times out of memory problems.

@fi3ework fi3ework reopened this Mar 30, 2022
@fi3ework
Copy link
Owner

fi3ework commented Mar 30, 2022

Hmm, a number of us are getting out-of-memory on 0.4.3 and we don't use Vue/vue-tsc. Any ideas?

Could you provide your vite config? Does the OOM occur after a long time of development without the process terminated?

@fi3ework
Copy link
Owner

Just an update after a few days using 0.4.4 and vue-tsc@0.33.9, most of the time is fine. However, I still experienced 2-3 times out of memory problems.

Does the OOM occur after a long time of development without the process terminated.

@jzs11
Copy link

jzs11 commented Mar 30, 2022

Just an update after a few days using 0.4.4 and vue-tsc@0.33.9, most of the time is fine. However, I still experienced 2-3 times out of memory problems.

Does the OOM occur after a long time of development without the process terminated.

That's correct.

@johnsoncodehk

This comment was marked as off-topic.

@ngokevin
Copy link

ngokevin commented Mar 30, 2022

Hmm, a number of us are getting out-of-memory on 0.4.3 and we don't use Vue/vue-tsc. Any ideas?

Could you provide your vite config? Does the OOM occur after a long time of development without the process terminated?

We have some preliminary results that it may be people had it crash after a few restarts on Node v12, but not Node v14.

export default defineConfig({
  build: {
    outDir: "vbuild",
    rollupOptions: {
      output: {
        manualChunks: undefined,
      },
    },
  },
  esbuild: {
    logLevel: "error",
  },
  plugins: [
    react(),
    checker({ overlay: false, typescript: true }),
    process.env.VISUALIZE && visualizer({ filename: "stats.html", open: true }),
  ],
  server: {
    fs: {
      strict: false,
      allow: ["..", "node_modules"],
    },
  },
  resolve: {
    alias: [
      ...aliases,
      // Need this for dat-gui but its kinda iffy
      { find: "node_modules", replacement: resolve(__dirname, "node_modules") },
    ],
  },
});

@jzs11
Copy link

jzs11 commented Mar 30, 2022

@jzs11 could you try move this code in node_modules/vue-tsc/out/proxy.js?

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createProgramProxy = void 0;
const ts = require("typescript/lib/tsserverlibrary");
const apis = require("./apis");
const vue_typescript_1 = require("@volar/vue-typescript");
const vue_typescript_2 = require("@volar/vue-typescript");
let projectVersion = 0;
+ const scripts = new Map();
function createProgramProxy(options, // rootNamesOrOptions: readonly string[] | CreateProgramOptions,
_options, _host, _oldProgram, _configFileParsingDiagnostics) {
    if (!options.options.noEmit && !options.options.emitDeclarationOnly)
        return doThrow('js emit is not support');
    if (!options.host)
        return doThrow('!options.host');
    projectVersion++;
    const host = options.host;
    const vueCompilerOptions = getVueCompilerOptions();
-    const scripts = new Map();

Hey dude, I did that, I will be using it for a few days to see things have been improved. Cheers.

@danielwaltz
Copy link

Hitting this issue too in a Vue 2 project using vue-tsc, eslint, and typescript. I run out of memory pretty quick using all three. It happens to be a very large project as well, so kind of a worst case scenario. I'm also using node v14.

@johnsoncodehk
Copy link

Please also track vuejs/language-tools#1108, it is break changes but it will reduce a half of memory usage.

@jzs11
Copy link

jzs11 commented Mar 31, 2022

With that code change, it happened once after few hours usage
image

@maiomiaoh
Copy link

image
I have the same problem!

@johnsoncodehk
Copy link

Does this problem resolved in vue-tsc 0.34 later?

@jzs11
Copy link

jzs11 commented Apr 24, 2022

I

Does this problem resolved in vue-tsc 0.34 later?

I have to stop using the checker due to this issue....

@maiolica
Copy link

Does this problem resolved in vue-tsc 0.34 later?

Situation got better (crash happens after ~15 mins vs ~5 mins in my case), but issue is still there.

@johnsoncodehk
Copy link

@maiolica Thanks for the information. Could you try run vue-tsc --noEmit --watch without vite-plugin-checker to check if the problem still have?

@maiolica
Copy link

@maiolica Thanks for the information. Could you try run vue-tsc --noEmit --watch without vite-plugin-checker to check if the problem still have?

Error happens after the first incremental compilation (project has ~1000 Vue components)

Error stack
[15:24:04] File change detected. Starting incremental compilation...


<--- Last few GCs --->

[34719:0x118008000]  9764258 ms: Mark-sweep 4032.2 (4130.9) -> 4016.5 (4131.2) MB, 2904.7 / 0.0 ms  (average mu = 0.085, current mu = 0.024) allocation failure scavenge might not succeed
[34719:0x118008000]  9767871 ms: Mark-sweep 4032.8 (4131.4) -> 4017.4 (4131.9) MB, 3481.9 / 0.0 ms  (average mu = 0.060, current mu = 0.036) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x104efc5d4 node::Abort() [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
2: 0x104efc754 node::OnFatalError(char const*, char const*) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
3: 0x10502c0a4 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
4: 0x10502c038 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
5: 0x105163fe8 v8::internal::Heap::GarbageCollectionReasonToString(v8::internal::GarbageCollectionReason) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
6: 0x1051668f0 v8::internal::Heap::MarkCompactPrologue() [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
7: 0x1051645b0 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
8: 0x105162a30 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
9: 0x10516b3a0 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
10: 0x10516b420 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
11: 0x10514912c v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
12: 0x1053d7c3c v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
13: 0x105651b4c Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
14: 0x10562e248 Builtins_MapIteratorPrototypeNext [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
15: 0x10c136d90 
16: 0x10dfb94e8 
17: 0x10c66fa20 
18: 0x10c8127d8 
19: 0x10dfb9bf4 
20: 0x10bca84bc 
21: 0x10bc3281c 
22: 0x10dfb9304 
23: 0x10c66fa20 
24: 0x10c8127d8 
25: 0x10dfb9bf4 
26: 0x10bca84bc 
27: 0x10bc32b14 
28: 0x10dfb9304 
29: 0x10bca84bc 
30: 0x10bc3281c 
31: 0x10bbde0e4 
32: 0x10c59881c 
33: 0x10de54364 
34: 0x10bbde6b0 
35: 0x10c5f8000 
36: 0x10c611090 
37: 0x10bcba050 
38: 0x10bcd3530 
39: 0x10c108468 
40: 0x10c7d06c4 
41: 0x10bd539b0 
42: 0x10d709190 
43: 0x10d714ac0 
44: 0x10c71c990 
45: 0x10c25d014 
46: 0x10bd64b70 
47: 0x10c7d04b0 
48: 0x10bd5b438 
49: 0x10da54a84 
50: 0x10c27bab4 
51: 0x10c5eb6b8 
52: 0x10bb35cf0 
53: 0x10bd5ee60 
54: 0x10c7d0e68 
55: 0x10c2b8498 
56: 0x10dafa524 
57: 0x10c6b609c 
58: 0x10c65e918 
59: 0x10c6b5224 
60: 0x10c65e918 
61: 0x10c829e04 
62: 0x10c6b621c 
63: 0x10c851da0 
64: 0x10c695650 
65: 0x10c6b6a5c 
66: 0x10c65e918 
67: 0x10c5e9b6c 
68: 0x10c6b664c 
69: 0x10c65e918 
70: 0x10bc28ee8 
71: 0x10d6a0c10 
72: 0x10d6b2644 
73: 0x10c16e974 
74: 0x10c7ce6f8 
75: 0x10c5ba764 
76: 0x10dd0aa4c 
77: 0x10dd0ab2c 
78: 0x10db631cc 
79: 0x10c274d7c 
80: 0x10d6f8694 
81: 0x1055e57d8 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
82: 0x1055e57d8 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
83: 0x1055e57d8 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
84: 0x1055e57d8 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
85: 0x1055e57d8 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
86: 0x1055e57d8 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
87: 0x1055e57d8 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
88: 0x1055e57d8 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
89: 0x1055e35cc Builtins_JSEntryTrampoline [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
90: 0x1055e3264 Builtins_JSEntry [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
91: 0x10510b2d8 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
92: 0x10510a988 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
93: 0x105040694 v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
94: 0x104eaebb0 node::Environment::RunTimers(uv_timer_s*) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
95: 0x10714399c uv__run_timers [/opt/homebrew/Cellar/libuv/1.44.1/lib/libuv.1.dylib]
96: 0x107146764 uv_run [/opt/homebrew/Cellar/libuv/1.44.1/lib/libuv.1.dylib]
97: 0x104e50b60 node::SpinEventLoop(node::Environment*) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
98: 0x104f312ec node::NodeMainInstance::Run(int*, node::Environment*) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
99: 0x104f30fbc node::NodeMainInstance::Run(node::EnvSerializeInfo const*) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
100: 0x104ed2670 node::Start(int, char**) [/opt/homebrew/Cellar/node@16/16.14.2/bin/node]
101: 0x1071a1088 
[1]    34719 abort      node_modules/vue-tsc/bin/vue-tsc.js --noEmit --watch
node 16.14.2
vue-tsc 0.34.10

@lmcsu
Copy link

lmcsu commented Jun 21, 2022

Hey guys,
I also get FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
from vue-tsc by itself by running vue-tsc --noEmit --watch
I think it's not the checker's issue.

@DhivinX
Copy link

DhivinX commented Jul 7, 2022

I have same problem:

node:events:368
      throw er; // Unhandled 'error' event
      ^

Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit: JS heap out of memory
    at new NodeError (node:internal/errors:371:5)
    at Worker.[kOnExit] (node:internal/worker:276:26)
    at Worker.<computed>.onexit (node:internal/worker:198:20)
Emitted 'error' event on Worker instance at:
    at Worker.[kOnExit] (node:internal/worker:276:12)
    at Worker.<computed>.onexit (node:internal/worker:198:20) {
  code: 'ERR_WORKER_OUT_OF_MEMORY'

@johnsoncodehk
Copy link

Please track vuejs/language-tools#1106.

@johnsoncodehk
Copy link

This problem should be fixed in vue-tsc v0.38.8.

@piotrpalek
Copy link

I've been hitting this lately in my project, any way to increase the memory limit? I'm using the checker({ typescript: true }) config.

image

@seedy
Copy link

seedy commented Mar 7, 2024

I have an error similar to @piotrpalek , breaking HMR. Disabling the checker plugin solves it.

node:events:495
      throw er; // Unhandled 'error' event
      ^

Error: Worker terminated due to reaching memory limit: JS heap out of memory
    at new NodeError (node:internal/errors:405:5)
    at [kOnExit] (node:internal/worker:287:26)
    at Worker.<computed>.onexit (node:internal/worker:209:20)
Emitted 'error' event on Worker instance at:
    at [kOnExit] (node:internal/worker:287:12)
    at Worker.<computed>.onexit (node:internal/worker:209:20) {
  code: 'ERR_WORKER_OUT_OF_MEMORY'
}

running my vite with the following environment var from #72 seems to reduce the frequency of this crash.

command:

    "start": "cross-env TSC_WATCHFILE=UseFsEventsWithFallbackDynamicPolling vite --host",

@moander
Copy link

moander commented Mar 22, 2024

I got this error after upgrading a Quasar project to use vue-tsc / plugin checker.

Adding some missing excludes to tsconfig.json solved the out-of-memory error for me:

{
  "extends": "@quasar/app-vite/tsconfig-preset",
  "compilerOptions": {
    "baseUrl": "."
  },
  "exclude": [
    "./dist",
    "./.quasar",
    "./node_modules",
    "./src-capacitor",
    "./src-cordova",
    "./quasar.config.*.temporary.compiled*"
  ]
}

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

No branches or pull requests