Skip to content

Fix launcher heap setup for long sessions - #1242

Merged
kevincodex1 merged 1 commit into
Twigpine:mainfrom
hicap-oss:issue-1221
May 25, 2026
Merged

kevincodex1 merged 1 commit into
Twigpine:mainfrom
hicap-oss:issue-1221

Conversation

@jatmn

@jatmn jatmn commented May 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Relaunch the package executable before importing dist/cli.mjs so long sessions start with an effective V8 heap cap.
  • Add --expose-gc during the relaunch and let Node sessions use global.gc alongside the existing Bun.gc path.
  • Preserve user-provided heap/GC flags from process.execArgv and NODE_OPTIONS, with opt-out/custom-size env hooks.
  • Add a launcher regression test for startup ordering and override handling.

Fixes #1221.

Validation

  • bun install --frozen-lockfile
  • bun test scripts/openclaude-bin-heap.test.ts src/entrypoints/cli.test.ts
  • bun run build
  • node bin/openclaude --version -> 0.13.0 (OpenClaude)

Note: bun run typecheck still reports existing repo-wide type errors unrelated to this change.

Relaunch the package executable before loading dist/cli.mjs so OpenClaude starts with an effective V8 heap cap instead of setting NODE_OPTIONS after the current process has already started.

The launcher now adds a default 8192 MB max-old-space-size and --expose-gc when they are missing, preserves flags supplied through process.execArgv or NODE_OPTIONS, and provides OPENCLAUDE_DISABLE_HEAP_RELAUNCH plus OPENCLAUDE_NODE_MAX_OLD_SPACE_SIZE_MB escape hatches.

Update the headless loop GC hook to use Node global.gc when the launcher exposed it, while preserving the existing Bun.gc path. Clarify the entrypoint NODE_OPTIONS comment so it reflects child-process propagation rather than current-process heap sizing.

Add scripts/openclaude-bin-heap.test.ts to guard launcher ordering and user override handling.

Validation: bun test scripts/openclaude-bin-heap.test.ts src/entrypoints/cli.test.ts; node bin/openclaude --version returned 0.13.0 (OpenClaude). Earlier full build passed after bun install --frozen-lockfile. bun run typecheck remains blocked by existing repo-wide type errors unrelated to this change.
@jatmn jatmn self-assigned this May 19, 2026
@Vasanthdev2004

Copy link
Copy Markdown
Collaborator

Blockers

None found.

Non-Blocking

None.

Looks Good

  • Fixes launcher heap setup for long sessions
  • 106 additions, 12 deletions — focused fix
  • From jatmn (co-maintainer)

Verdict: Approve — clean heap fix.

@Vasanthdev2004 Vasanthdev2004 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean heap fix.

@kevincodex1
kevincodex1 merged commit cb666c8 into Twigpine:main May 25, 2026
2 checks passed
@jatmn
jatmn deleted the issue-1221 branch May 25, 2026 17:07
jasonkelly007 pushed a commit to jasonkelly007/openclaude that referenced this pull request May 26, 2026
Ensures package.json scripts (dev, start), scripts/provider-launch.ts,
and Dockerfile route node executions through the bin/openclaude launcher
rather than calling node directly on dist/cli.mjs.

This resolves PR feedback:
1. Preserves the robust launcher relaunch guard, GC exposure, and test
   coverage already merged on main (from Twigpine#1242).
2. Prevents hardcoded heap caps (--max-old-space-size=8192) from overriding
   user-provided NODE_OPTIONS or OPENCLAUDE_NODE_MAX_OLD_SPACE_SIZE_MB
   settings during development, start, or containerized runs.
kevincodex1 pushed a commit that referenced this pull request May 27, 2026
Ensures package.json scripts (dev, start), scripts/provider-launch.ts,
and Dockerfile route node executions through the bin/openclaude launcher
rather than calling node directly on dist/cli.mjs.

This resolves PR feedback:
1. Preserves the robust launcher relaunch guard, GC exposure, and test
   coverage already merged on main (from #1242).
2. Prevents hardcoded heap caps (--max-old-space-size=8192) from overriding
   user-provided NODE_OPTIONS or OPENCLAUDE_NODE_MAX_OLD_SPACE_SIZE_MB
   settings during development, start, or containerized runs.

Co-authored-by: daltoncoder <daltoncoder@example.com>
discopops pushed a commit to discopops/openclaude that referenced this pull request May 28, 2026
Relaunch the package executable before loading dist/cli.mjs so OpenClaude starts with an effective V8 heap cap instead of setting NODE_OPTIONS after the current process has already started.

The launcher now adds a default 8192 MB max-old-space-size and --expose-gc when they are missing, preserves flags supplied through process.execArgv or NODE_OPTIONS, and provides OPENCLAUDE_DISABLE_HEAP_RELAUNCH plus OPENCLAUDE_NODE_MAX_OLD_SPACE_SIZE_MB escape hatches.

Update the headless loop GC hook to use Node global.gc when the launcher exposed it, while preserving the existing Bun.gc path. Clarify the entrypoint NODE_OPTIONS comment so it reflects child-process propagation rather than current-process heap sizing.

Add scripts/openclaude-bin-heap.test.ts to guard launcher ordering and user override handling.

Validation: bun test scripts/openclaude-bin-heap.test.ts src/entrypoints/cli.test.ts; node bin/openclaude --version returned 0.13.0 (OpenClaude). Earlier full build passed after bun install --frozen-lockfile. bun run typecheck remains blocked by existing repo-wide type errors unrelated to this change.
discopops pushed a commit to discopops/openclaude that referenced this pull request May 28, 2026
…ine#1363)

Ensures package.json scripts (dev, start), scripts/provider-launch.ts,
and Dockerfile route node executions through the bin/openclaude launcher
rather than calling node directly on dist/cli.mjs.

This resolves PR feedback:
1. Preserves the robust launcher relaunch guard, GC exposure, and test
   coverage already merged on main (from Twigpine#1242).
2. Prevents hardcoded heap caps (--max-old-space-size=8192) from overriding
   user-provided NODE_OPTIONS or OPENCLAUDE_NODE_MAX_OLD_SPACE_SIZE_MB
   settings during development, start, or containerized runs.

Co-authored-by: daltoncoder <daltoncoder@example.com>
Gravirei added a commit to Gravirei/openclaude that referenced this pull request May 28, 2026
- fix(autocompact): retry circuit breaker after cooldown (Twigpine#1375)
- fix(provider): require API key input when adding OpenGateway (Twigpine#1384)
- fix(provider): allow remote Ollama without OPENAI_API_KEY (Twigpine#952)
- fix(codex-stream): recover tool args delivered only via done events (Twigpine#1262)
- fix: route MiniMax compacting through Anthropic-compatible API (Twigpine#1154)
- fix(thinking): disable thinking for unsupported Ollama models (Twigpine#1376)
- feat(agents): set active session agent from agents menu (Twigpine#1349)
- fix(repl): show permission prompts while draft input is present (Twigpine#1393)
- fix(model): include profile models in descriptor picker (Twigpine#1361)
- Improve warning notice formatting (Twigpine#1415)
- fix(codex): allow credential storage fallback (Twigpine#1347)
- fix(attribution): make git attribution opt-in by default (Twigpine#1335)
- fix(agent): allow custom model overrides (Twigpine#1337)
- feat(query): robust multi-lingual and structural continuation nudge (Twigpine#1280)
- fix(watchers): debounce skills and settings reload bursts (Twigpine#1370)
- feat: configure API retry backoff (Twigpine#370) (Twigpine#1095)
- chore(main): release 0.15.0 (Twigpine#1325)
- ci: retrigger CodeQL after action download outage (Twigpine#1374)
- Fix launcher heap setup for long sessions (Twigpine#1242)
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.

JavaScript out-of-memory error

3 participants