Skip to content

fix(session): use forceDestroy() to reap orphaned Chromium on init failure#631

Merged
rmyndharis merged 2 commits into
rmyndharis:mainfrom
m7fz7:fix/session-crash-cleanup
Jul 5, 2026
Merged

fix(session): use forceDestroy() to reap orphaned Chromium on init failure#631
rmyndharis merged 2 commits into
rmyndharis:mainfrom
m7fz7:fix/session-crash-cleanup

Conversation

@m7fz7

@m7fz7 m7fz7 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Description

SessionService.start()'s crash-recovery path tore down a half-built engine with a graceful destroy(), but a failed engine.initialize() usually means the browser/CDP connection is already broken (e.g. TargetCloseError: Target closed mid script-injection). destroy() has nothing live to talk to in that case — it can only time out via teardownEngineSafely's 10s race and give up, leaving the Chromium process alive and orphaned. Every such crash leaves one more zombie process behind, eventually exhausting host memory and causing subsequent start attempts to fail too (including "The browser is already running for <userDataDir>" from the still-held profile lock).

Switched that one teardown call to forceDestroy() — the same SIGKILL-the-process recovery POST /:id/force-kill already uses for a wedged engine, which is exactly the state this catch block is handling.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • Tests added/updated
  • Documentation updated
  • Lint passes
  • Self-reviewed

Screenshots (if applicable)

N/A — backend-only change, no UI surface.

Related Issues

Closes #

m7fz7 and others added 2 commits July 5, 2026 18:52
…ilure

start()'s crash-recovery path tore down a half-built engine with a graceful
destroy(), but a failed engine.initialize() usually means the underlying
browser/CDP connection is already broken (e.g. a TargetCloseError: Target
closed mid script-injection). destroy() has nothing live to talk to in that
case, so it can only time out via teardownEngineSafely's 10s race, leaving
the Chromium process alive and orphaned. Every such crash left one more
process behind, eventually starving the host of memory.

Use forceDestroy() instead, the same SIGKILL-the-process recovery
POST /:id/force-kill already uses for a wedged engine -- the exact state
this catch block is handling.
@rmyndharis rmyndharis merged commit ddcc660 into rmyndharis:main Jul 5, 2026
5 checks passed
@m7fz7 m7fz7 deleted the fix/session-crash-cleanup branch July 5, 2026 15:38
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.

2 participants