Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(chromium): fix crash if connecting to a browser with a serviceworker #5803

Merged
merged 1 commit into from
Mar 15, 2021

Conversation

JoelEinbinder
Copy link
Contributor

@JoelEinbinder JoelEinbinder commented Mar 11, 2021

Target.setAutoAttach appears to connect to service workers again, which causes us to crash with duplicate target errors. Also service workers that were created before connecting to the browser were incorrectly dispatched to the client layer.

Fixes #5648

// are created automatically and may be initialized before we enable auto-attach.
// Their service workers are also automatically created, but setAutoAttach attaches to them.
Copy link
Member

Choose a reason for hiding this comment

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

huh

@JoelEinbinder
Copy link
Contributor Author

@dgozman you suggested just deleting all the Target.setDiscoverTargets code. It appears to work! ptal

src/server/chromium/crBrowser.ts Show resolved Hide resolved
@@ -59,32 +62,11 @@ export class CRBrowser extends Browser {
}
browser._defaultContext = new CRBrowserContext(browser, undefined, options.persistent);

const existingTargetAttachPromises: Promise<any>[] = [];
// First page, background pages and their service workers in the persistent context
// are created automatically and may be initialized before we enable auto-attach.
Copy link
Member

Choose a reason for hiding this comment

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

How can we be sure that scenario mentioned in the comment is still handled correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are new tests for what's described in this comment.

@JoelEinbinder JoelEinbinder merged commit defd1a3 into microsoft:master Mar 15, 2021
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.

[BUG] Error: Duplicate target when trying to connectOverCDP next time
3 participants