Skip to content

Connect to a chrome.runtime port to keep the service worker alive #1789

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

Merged
merged 14 commits into from
Nov 18, 2022

Conversation

elliette
Copy link
Contributor

Implements the workaround described in https://bugs.chromium.org/p/chromium/issues/detail?id=1152255#c21

Has the connected Dart app tab connect to a chrome.runtime port. The service worker listens for the onConnect event, and starts a timer to reconnect after 5 minutes (the service worker lifetime).

@elliette elliette requested a review from annagrin November 12, 2022 00:19
Copy link
Contributor

@annagrin annagrin left a comment

Choose a reason for hiding this comment

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

LGTM with a comment.

.firstWhere((url) => url.contains(chromeExtension));
final urlSegments = p.split(extensionUrl);
final extensionId = urlSegments[urlSegments.indexOf(chromeExtension) + 1];
return '$chromeExtension//$extensionId';
Copy link
Contributor

Choose a reason for hiding this comment

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

I know that we are currently not running this on windows, but it would save us an additional break when we do:
can we use platform-independent directory separator, i.e: p.join('chromeExtension, extensionId)?

Copy link
Contributor Author

@elliette elliette Nov 18, 2022

Choose a reason for hiding this comment

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

Done! Using p.join wherever possible. In this case it's creating a non-standard Chrome extension URI (eg chrome-extension://abcdefg), not a file URI. I couldn't find a path utility method to support that.

@elliette elliette merged commit 9cc10d4 into dart-lang:master Nov 18, 2022
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