Skip to content

fix(cli): heap cap overrides the operator, and tray mode re-enables autostart (#3365, #3628) - #3881

Open
ntdatt812 wants to merge 2 commits into
decolua:masterfrom
ntdatt812:bundle/cli-desktop
Open

ntdatt812 wants to merge 2 commits into
decolua:masterfrom
ntdatt812:bundle/cli-desktop

Conversation

@ntdatt812

Copy link
Copy Markdown
Contributor

Two CLI/desktop fixes that were sitting in separate PRs (#3368, #3651), rebased onto current master. Independent commits.

fix(cli) (#3365) — a hard-coded heap cap overrode the operator's own --max-old-space-size. The launcher appended its default after the user's flags, and Node takes the last occurrence, so raising the cap for a large workload silently did nothing.

fix(cli) (#3628) — switching to tray mode re-enabled autostart every time, even for a user who had explicitly turned it off. The tray path called the enable routine unconditionally instead of honouring the stored choice.

Verification

Run with vitest 3 and the repo config — both parts matter:

npx vitest@3 run --config tests/vitest.config.js <files>

Without --config the @/ alias does not resolve (Failed to load url @/lib/dataDir.js). And vitest 2.x cannot run anything that reaches open-sse/translator/index.js: it throws TypeError: register is not a function at the top-level register(...) calls, because index.js deliberately relies on function-declaration hoisting to survive the import cycle while Vite 5's SSR transform turns the named import into a call-time property access. I confirmed that failure on clean master and on master as of 15 Aug, so it is not caused by these changes.

Every fix was checked by reverting it and confirming which test dies. No claim here rests on a test that passes for another reason.

The next-server child is spawned with --max-old-space-size=6144 on the command
line. Node reads NODE_OPTIONS first and lets command-line flags win, so that
value cannot be lowered from outside: on a host with a cgroup limit (systemd
MemoryMax, docker --memory, k8s) the child runs believing it has 6 GB of heap.
GC never feels the limit, RSS climbs to the ceiling, and the kernel OOM-kills
next-server — taking in-flight streaming responses with it. The supervisor
restarts and it happens again.

The default is unchanged for the desktop case it was raised for. It now steps
aside once the operator has said what they want:

- NINEROUTER_MAX_OLD_SPACE_SIZE=384 caps the heap at 384 MB; 0 passes no flag
  at all and lets node size the heap from the memory it can see.
- A --max-old-space-size already present in NODE_OPTIONS is respected rather
  than overridden, so the standard mechanism finally works.

A junk value keeps the default and warns, rather than quietly leaving the heap
uncapped — losing a safety cap to a typo is the wrong failure direction.

Deriving the default from available memory is deliberately not done here:
os.totalmem() reports the host's RAM, not the cgroup limit, so it would not
help the containerised case that motivates this and would change behaviour
everywhere else.

Reported in decolua#3365, and previously in decolua#1982.
Switching to tray mode called enableAutoStart() unconditionally, so neither
way of turning autostart off survived a restart: the tray's "Disable" was
undone by the next hide, and deleting the startup entry by hand was undone
too. The report is filed against Windows, but the call is platform-agnostic
and macOS and Linux behave the same.

Split the automatic path from the deliberate one. ensureAutoStart() writes an
entry only until the choice has been made once -- by it, or by an explicit
enable or disable -- and records that in the CLI's data directory.
enableAutoStart() and disableAutoStart() stay deliberate and always write.

A first install still gets autostart on its first hide, as before.

Fixes decolua#3628
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant