Skip to content

launch: make browserClose actually close the context and browser (fixes #80) - #81

Open
wittjeff wants to merge 1 commit into
jrpool:mainfrom
wittjeff:fix/browser-close
Open

launch: make browserClose actually close the context and browser (fixes #80)#81
wittjeff wants to merge 1 commit into
jrpool:mainfrom
wittjeff:fix/browser-close

Conversation

@wittjeff

Copy link
Copy Markdown
Collaborator

Fixes #80.

browserClose referenced page.context and browserContext.browser as properties, but they are Playwright methods. page.context therefore yielded a function object, whose absent close method made the close attempt throw a TypeError that the empty catch block discarded, and whose absent browser property made the browser-close branch unreachable. So browserClose silently closed nothing: every browser launched in the main process outlived its act until the process exited, and browsers launched in forked tool children survived until the child exited.

This PR calls the methods instead. browserContext.browser() returns null for a context not owned by a browser (e.g. a persistent context, as proposed in #77); the existing if (browser) guard covers that.

Verification

🤖 Generated with Claude Code

browserClose referenced page.context and browserContext.browser as
properties, but they are methods. page.context therefore yielded a
function object, whose absent close method made the close attempt
throw a TypeError that the empty catch block discarded, and whose
absent browser property made the browser-close branch unreachable. So
browserClose silently closed nothing: every browser launched in the
main process outlived its act until the process exited, and browsers
launched in forked tool children survived until the child exited.

Call the methods instead. browserContext.browser() is null for a
context not owned by a browser; the existing guard covers that.

Verified: after browserClose(page), browser.isConnected() is now
false (previously true); single-act and multi-act jobs produce
results identical to before the change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.

browserClose in procs/launch.js silently closes nothing (page.context and context.browser referenced as properties, not methods)

1 participant