Skip to content

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

Closed
m7fz7 wants to merge 10 commits into
rmyndharis:mainfrom
m7fz7:fix/session-crash-cleanup
Closed

fix(session): use forceDestroy() to reap orphaned Chromium on init failure#630
m7fz7 wants to merge 10 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.

m7fz7 and others added 10 commits June 25, 2026 18:16
…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.
@m7fz7 m7fz7 marked this pull request as draft July 5, 2026 14:49
@m7fz7 m7fz7 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