Skip to content

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

Merged
yury-s merged 1 commit into
microsoft:mainfrom
hbenl:dispose-all-sessions
Jun 15, 2026
Merged

chore(bidi): dispose all sessions when connection is closed#41271
yury-s merged 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I couldn't think of a cleaner approach either.

@hbenl hbenl force-pushed the dispose-all-sessions branch from 3d5d902 to 4620d9b Compare June 15, 2026 11:27
@hbenl hbenl force-pushed the dispose-all-sessions branch from 4620d9b to 6a9d07b Compare June 15, 2026 12:01
@yury-s yury-s merged commit 2061eac into microsoft:main Jun 15, 2026
3 of 4 checks passed
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