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

feat: idle syncing #269

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/extension/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"matches": ["<all_urls>"]
}
],
"permissions": ["storage", "unlimitedStorage", "offscreen"],
"permissions": ["storage", "unlimitedStorage", "offscreen", "alarms"],
"host_permissions": ["<all_urls>"],
"externally_connectable": {
"matches": ["<all_urls>"]
Expand Down
6 changes: 6 additions & 0 deletions apps/extension/src/service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,9 @@ const handler = await backOff(() => initHandler(), {
});

CRSessionManager.init(PRAX, handler);

// https://developer.chrome.com/docs/extensions/reference/api/alarms
void chrome.alarms.create('blockSync', {
periodInMinutes: 30,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

dynamically adjustable param

Copy link

Choose a reason for hiding this comment

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

FWIW, I think it will have to be much shorter than this (between 20 seconds and 4 minutes)

https://developer.chrome.com/docs/extensions/develop/concepts/service-workers/lifecycle

Screenshot 2025-01-21 at 7 52 48 AM

Copy link

Choose a reason for hiding this comment

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

I don't totally understand what causes the service worker to terminate, if it's long-polling the compact block stream or real idling.

Copy link
Contributor Author

@TalDerei TalDerei Jan 21, 2025

Choose a reason for hiding this comment

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

FWIW, I think it will have to be much shorter than this (between 20 seconds and 4 minutes)

alarms can now be set to a minimum period of 30s to match the service worker lifecycle: "starting in Chrome 120, the minimum alarm interval has been reduced from 1 minute to 30 seconds"

I've been testing locally with 1 minute.

delayInMinutes: 0,
});