chore(bidi): dispose all sessions when connection is closed#41271
Open
hbenl wants to merge 1 commit into
Open
Conversation
42cd241 to
3d5d902
Compare
yury-s
approved these changes
Jun 12, 2026
| this._transport.onclose = undefined; | ||
| this._browserDisconnectedLogs = helper.formatBrowserLogs(this._browserLogsCollector.recentLogs(), reason); | ||
| for (const session of this._browsingContextToSession.values()) | ||
| session.dispose(); |
Member
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes "should reject all promises when browser is closed" in
library/browsertype-launch.spec.tsand "should dispatch page.on(close) upon browser.close and reject evaluate" inlibrary/browser.spec.ts.