Skip to content

fix: clean up extension spawn lifecycle - #585

Closed
JustYannicc wants to merge 115 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-wave4-extension-spawn-lifecycle
Closed

fix: clean up extension spawn lifecycle#585
JustYannicc wants to merge 115 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-wave4-extension-spawn-lifecycle

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Added ExtensionView-scoped tracking for child_process.spawn, exec, and execFile children created through the renderer IPC shim.
  • Unmount cleanup now removes active spawn IPC listeners and requests termination for outstanding extension-spawned children.
  • Main now indexes spawned processes by originating webContents and reaps only that sender's children on destroyed or render-process-gone, while preserving explicit spawn-kill behavior.

Why

Long-running extension child processes could survive ExtensionView unmounts, leaving renderer IPC listeners and main-process map entries alive until the child exited naturally.

Compatibility impact

Existing stdout/stderr streaming, terminal events, stdin forwarding, process-group termination, spawn, exec, execFile, and legacy spawn IPC channels are preserved. Cleanup is scoped to the ExtensionView or originating sender so unrelated processes are not terminated.

How tested

  • node --test scripts/test-extension-lifecycle-sandbox.mjs
  • npm run typecheck:renderer
  • npm run build:main
  • Codex LSP diagnostics for src/renderer/src/ExtensionView.tsx: no diagnostics found
  • Codex LSP diagnostics for src/main/main.ts: no diagnostics found
  • npm test (312 tests reported, 310 passed, 2 skipped)

Performance evidence

Before: active extension spawn cleanup was not part of the ExtensionView lifecycle registry, so an unmounted view could retain 1 spawn IPC listener and 1 tracked long-running child until process exit.

After: scripts/test-extension-lifecycle-sandbox.mjs logs extension child_process lifecycle cleanup after fix with activeSpawnIpcListeners: 1 -> 0, trackedChildProcesses: 1 -> 0, cleanupCalls: 0 -> 1, and killCalls: 0 -> 1 when the registry is cleared.

Stack validation

Started from codex/perf-wave3-integration-stack-20260704 at 206eab8280a2eb91a57e4e74ea6df99e45a55cb4. Final branch commit: 23ddb55106f837faf6bcbc8d0705ea696ebe5f75.

Replaces

None.

…perf-wave2-integration-stack-20260704

# Conflicts:
#	src/renderer/src/raycast-api/hooks/use-cached-promise.ts
…perf-wave2-integration-stack-20260704

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime-renderers.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
…perf-wave2-integration-stack-20260704

# Conflicts:
#	src/renderer/src/CameraExtension.tsx
…perf-wave2-integration-stack-20260704

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime.tsx
…perf-wave2-integration-stack-20260704

# Conflicts:
#	scripts/bench-script-command-discovery.mjs
#	scripts/benchmark-file-search-delete-batch.mjs
#	scripts/lib/script-command-runner-harness.mjs
#	scripts/lib/ts-import.mjs
#	scripts/test-file-search-delete-batch.mjs
#	scripts/test-script-command-runner.mjs
#	src/main/file-search-index.ts
#	src/main/main.ts
…perf-wave2-integration-stack-20260704

# Conflicts:
#	scripts/lib/script-command-runner-harness.mjs
#	scripts/lib/ts-import.mjs
#	scripts/test-extension-lifecycle-sandbox.mjs
#	scripts/test-script-command-runner.mjs
#	src/main/main.ts
#	src/renderer/src/ExtensionView.tsx
…perf-wave2-integration-stack-20260704

# Conflicts:
#	.github/workflows/project-checks.yml
#	scripts/test-root-search-perf.mjs
#	src/renderer/src/CameraExtension.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
…erf-wave3-integration-stack-20260704

# Conflicts:
#	package.json
#	scripts/measure-extension-bundle-cache.mjs
#	scripts/test-icon-runtime-file-icon-cache.mjs
#	src/main/extension-runner.ts
#	src/renderer/src/components/HiddenExtensionRunners.tsx
#	src/renderer/src/raycast-api/icon-runtime-render.tsx
…/perf-wave3-integration-stack-20260704

# Conflicts:
#	scripts/test-browser-search-performance.mjs
#	scripts/test-root-search-perf.mjs
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #601, which fully replaces this granular PR in the wave4 runtime/main consolidation. Literal validation now passes with /opt/homebrew/opt/node@22/bin/npm run build:main, and #601 is ready for review.

@JustYannicc JustYannicc closed this Jul 5, 2026
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