Skip to content

Frontend dev server (ng serve) crashes with "JavaScript heap out of memory" on rebuild for lower-RAM machines #6859

Closed

Description

@gupta-sahil01

What happened?

yarn start runs ng serve with no --max-old-space-size flag, so the dev server uses Node's default V8 heap. On a machine where that default is ~2 GB, the very first incremental rebuild after any source edit pushes the webpack build past the heap limit and Node aborts:

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
ng serve exited with code SIGABRT

Because the start script uses concurrently --kill-others, the ng-serve crash immediately kills the sibling y-websocket process too, so the whole yarn start dies and :4200 stops responding ("cannot resolve host"). It does not recover on its own — the only way back is to restart the dev server (or the whole local-dev stack).

Expected: editing a frontend file should trigger a normal hot-reload; the dev server should stay up.

Note the inconsistency: the build script already runs Angular under node --max-old-space-size=8192, but start (ng serve) does not. So production builds are protected and the dev server is not.

Why it doesn't reproduce for everyone: Node auto-sizes the default heap from physical RAM. On an 8 GB machine the default is ~2.24 GB (crashes); on 16 GB+ machines the default is large enough that the rebuild fits, so those contributors never see it. This is why it has gone unnoticed — it only bites lower-RAM machines.

How to reproduce?

  1. Bring up the frontend dev server (bin/local-dev.sh up frontend, i.e. cd frontend && yarn start).
  2. On a machine with ~8 GB RAM (Node default heap ~2.2 GB — verify with:
    node -e "console.log(require('v8').getHeapStatistics().heap_size_limit/1024/1024)").
  3. Open http://localhost:4200 and confirm it loads.
  4. Make any trivial edit to a template, e.g. remove/add a line in
    frontend/src/app/hub/component/about/about.component.html, and save.
  5. Observe: the incremental rebuild OOMs, ng serve exits with SIGABRT,
    --kill-others terminates y-websocket, and :4200 becomes unreachable.

Proposed fix: give ng serve the same heap ceiling build already uses, e.g.

"start": "concurrently --kill-others \"npx y-websocket\" \"node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng serve\"",

Verified: with the flag, the identical edit recompiles ("Compiled successfully") and :4200 stays up; zero OOM across repeated rebuilds.

Version/Branch

1.3.0-incubating-SNAPSHOT (main)

Commit Hash (Optional)

181e38b

What browsers are you seeing the problem on?

No response

Relevant log output

[1] <--- Last few GCs --->
[1] [83836:0xa0940c000]  873898 ms: Scavenge (interleaved) 2034.8 (2049.9) -> 2034.7 (2054.1) MB ... allocation failure;
[1] [83836:0xa0940c000]  875337 ms: Mark-Compact 2040.3 (2057.0) -> 2039.8 (2067.5) MB ... allocation failure; scavenge might not succeed
[1] FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
[1]  1: 0x10474f848 node::OOMErrorHandler(char const*, v8::OOMDetails const&)
[1]  2: 0x10494ea14 v8::internal::V8::FatalProcessOutOfMemory(...)
[1] ng serve exited with code SIGABRT
--> Sending SIGTERM to other processes..
[0] npx y-websocket exited with code SIGTERM

Activity

  1. KYinXu commented on Jul 24, 2026

    @KYinXu
    Contributor

    /take

  2. gupta-sahil01 commented on Jul 25, 2026

    @gupta-sahil01
    ContributorAuthor

    @KYinXu I plan to resolve this once I receive approval from the devs that this is a valid bug.

  3. KYinXu commented on Jul 25, 2026

    @KYinXu
    Contributor

    Ok, I'll leave it to you then.

  4. KYinXu commented on Jul 25, 2026

    @KYinXu
    Contributor

    /untake

  5. chenlica commented on Jul 26, 2026

    @chenlica
    Contributor

    @gupta-sahil01 If you can produce the issue, feel free to "take" it and solve it.

  6. gupta-sahil01 commented on Jul 26, 2026

    @gupta-sahil01
    ContributorAuthor

    /take

  7. added a commit that references this issue on Jul 30, 2026
    2ec3b0a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions