Skip to content

chore(bidi): dispose all sessions when connection is closed#41271

Open
hbenl wants to merge 1 commit into
microsoft:mainfrom
hbenl:dispose-all-sessions
Open

chore(bidi): dispose all sessions when connection is closed#41271
hbenl wants to merge 1 commit into
microsoft:mainfrom
hbenl:dispose-all-sessions

Conversation

@hbenl

@hbenl hbenl commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Fixes "should reject all promises when browser is closed" in library/browsertype-launch.spec.ts and "should dispatch page.on(close) upon browser.close and reject evaluate" in library/browser.spec.ts.

@hbenl hbenl force-pushed the dispose-all-sessions branch from 42cd241 to 3d5d902 Compare June 12, 2026 17:40
this._transport.onclose = undefined;
this._browserDisconnectedLogs = helper.formatBrowserLogs(this._browserLogsCollector.recentLogs(), reason);
for (const session of this._browsingContextToSession.values())
session.dispose();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe this should be a part of BidiSession.dispose() which already deletes the child sessions from _browsingContextToSession map.

This session management code is more convoluted than it needs to be. The idea was to have hierarchy of Browser->Page->Frame sessions, but unfortunately there is no unified way to route the messages and we ended up with the ugly BidiConnection._dispatchMessage logic. Perhaps you have an idea how to improve it? I was contemplating just giving up on the unified routing and instead having particular classes route delegate to their child sessions, but didn't quite like it either.

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.

2 participants