Skip to content

fix(browser): stop the process when quit is interrupted while closing the connection - #740

Merged
route merged 1 commit into
mainfrom
fix/interrupted-quit
Nov 27, 2026
Merged

route merged 1 commit into
mainfrom
fix/interrupted-quit

Conversation

@route

@route route commented Nov 27, 2026

Copy link
Copy Markdown
Member

Follow-up to #738, which made Client#close clean up its threads and socket when interrupted. Browser#quit had the same gap one level up:

@client.close
thread = @process.stop(wait: wait)
@client = @process = @contexts = nil

A browser that hangs without dying never answers the close frame, so Client#close waits up to a second for its thread. An interrupt landing in that second, such as Timeout.timeout { browser.quit }, Thread#raise or Ctrl-C, skipped @process.stop. A Chrome that Ferrum launched kept running, and the Browser still held the closed client. restart calls quit, so it had the same problem.

quit now stops the process and clears its state in an ensure. The interrupt still reaches the caller, after the process is gone. The early return when there's no client stays outside it, so a second quit is still a no-op.

… the connection

A hung browser never answers the close frame, so Client#close waits up to a second for its thread. An interrupt landing
in that wait, e.g. Timeout.timeout or Thread#raise, skipped @process.stop in quit, leaving a launched Chrome running and
the browser still holding the client. quit stops the process and clears its state in an ensure now, restart included.
@route
route force-pushed the fix/interrupted-quit branch from 1e22c4a to 4ef4e9c Compare November 27, 2026 17:49
@route
route merged commit 280cb0f into main Nov 27, 2026
6 of 7 checks passed
@route
route deleted the fix/interrupted-quit branch November 27, 2026 18:07
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