-
Notifications
You must be signed in to change notification settings - Fork 83
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
Conversation
There was a problem hiding this 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'; |
There was a problem hiding this comment.
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)
?
There was a problem hiding this comment.
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.
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 theonConnect
event, and starts a timer to reconnect after 5 minutes (the service worker lifetime).