Skip to content

fix(core): order browser teardown safely - #26

Merged
ElbertePlinio merged 8 commits into
mainfrom
fix/browser-contract-teardown-order
Jul 12, 2026
Merged

ElbertePlinio merged 8 commits into
mainfrom
fix/browser-contract-teardown-order

Conversation

@ElbertePlinio

@ElbertePlinio ElbertePlinio commented Jul 12, 2026 •

Copy link
Copy Markdown
Member

Changed

  • Rebase the complete browser session/process contract slice onto current main.
  • Stop and confirm the recorded browser process group before VNC/Xvfb helpers.
  • Verify group leadership, zombie ownership, and PID identity before signaling.
  • Fail closed on reused or unconfirmed identities and preserve errored records when helpers survive.
  • Keep Chrome lifecycle packages and CLI/MCP browser creation out of this slice.

Supersedes #24.

Validated

  • bun run typecheck
  • bun run test — 622 passed, 2 skipped
  • bun run test:coverage — thresholds met
  • bun run build
  • bun run test packages/core — 8 files, 107 passed

Not tested

  • Real Chrome lifecycle; remains in the later lifecycle slice.

Refs #17
Refs #18

@ElbertePlinio
ElbertePlinio force-pushed the fix/browser-contract-teardown-order branch from 1fbfd02 to 01cc5ff Compare July 12, 2026 20:08
@ElbertePlinio

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 01cc5ffd38

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Require verified process-group leadership and preserve errored session records when browser or helper teardown is uncertain.
@ElbertePlinio

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c43602c31d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/proc.ts Outdated
): Promise<StopProcessGroupResult> {
const timeoutMs = opts.timeoutMs ?? 5_000;
const leader = readProcStat(identity.pid);
if (leader === undefined || leader.state === "Z") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle zombie group leaders before failing closed

When the recorded browser leader has exited into Z but a child/renderer is still alive in the same process group, /proc/<pid>/stat still has the matching start time and pgrp, so the group is still verifiable and safe to signal. This branch returns reused without signaling, which makes reapDeadRunningSessions mark the session error and leave the browser children plus VNC/Xvfb helpers running. Treat zombies as dead only when the group has no live members, or allow a matching zombie leader to proceed to group termination.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in c98452e. A matching zombie leader with live non-zombie group members now remains a verified group owner, so teardown signals the group. Missing leaders, reused identities, and non-leaders still fail closed. Added a focused regression; full test, coverage, typecheck, and build are green.

Allow verified zombie leaders to retain ownership of live browser group members so teardown can remove the complete process tree.
@ElbertePlinio

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: c98452e5cb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ElbertePlinio
ElbertePlinio merged commit fc49170 into main Jul 12, 2026
1 check passed
@ElbertePlinio
ElbertePlinio deleted the fix/browser-contract-teardown-order branch July 12, 2026 21:25
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