Skip to content

fix(runtime): close browser after partial session teardown failures - #15

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cacritical-bug-management-18df
Draft

fix(runtime): close browser after partial session teardown failures#15
cursor[bot] wants to merge 1 commit into
mainfrom
cacritical-bug-management-18df

Conversation

@cursor

@cursor cursor Bot commented Jul 27, 2026

Copy link
Copy Markdown

Bug and impact

BrowserRuntime.shutdown() used Promise.all over context.close() calls. When any session context failed to close, the rejection aborted shutdown before browser.close() ran, leaving orphan Chromium/WebKit processes after companion SIGTERM/SIGINT.

Root cause

All-or-nothing Promise.all semantics in packages/runtime/src/index.ts, plus companion signal handler that did not guarantee app.close() when runtime.shutdown() threw.

Fix and validation

  • Switch shutdown to Promise.allSettled with best-effort per-session cleanup, then always attempt browser.close().
  • Wrap companion graceful shutdown in try/finally so Fastify always closes.
  • Added unit test: shutdown still calls browser.close() when one of two session contexts rejects.

pnpm --filter @webchain/runtime test — 26 passed.

Open in Web View Automation 

Promise.all in shutdown() aborted on the first context.close() error,
skipping browser.close() and leaving orphan Chromium processes. Use
allSettled with best-effort per-session cleanup and wrap companion
SIGTERM/SIGINT handling so app.close() always runs.

Co-authored-by: esadrianno <esadrianno@gmail.com>
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