-
Notifications
You must be signed in to change notification settings - Fork 402
chore(clerk-js): Pause/resume session touch while offline #5098
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
chore(clerk-js): Pause/resume session touch while offline #5098
Conversation
🦋 Changeset detectedLatest commit: 1366045 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
6198e4c to
eb6d12f
Compare
8847d45 to
9184b06
Compare
.changeset/breezy-dogs-greet.md
Outdated
| '@clerk/clerk-js': patch | ||
| --- | ||
|
|
||
| Pause session touch when browser is offline, and resume it when the device comes back online. |
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.
Can you include the token polling also?
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.
🔥 Great work!
This reverts commit f4bd403.
5bb7abb to
0e8d7b9
Compare
This reverts commit 40d0c80.
This reverts commit 649981c.
|
This improvement uncovered a bug with our sign-out broadcasting solution, avoid merging until resolved. |
| // is updated as part of the scheduled microtask. Our existing event-based mechanism to update the cookie schedules a task, and so the cookie | ||
| // is updated too late and not guaranteed to be fresh before the refetch occurs. | ||
| void this.refreshSessionToken({ updateCookieImmediately: true }); | ||
| this.offlineScheduler.schedule(() => this.refreshSessionToken({ updateCookieImmediately: true })); |
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.
we need to make sure wrapping this call doesn't impact the behavior described in the comment above.
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.
While online, we are executing it instantly, so it does not affect the behaviour the comment describes. While offline, I think it still works, because the application requests will either fail, or will not fire and when they do fire the libraries will still use setTimeout(cb,0).
packages/clerk-js/src/core/clerk.ts
Outdated
| #options: ClerkOptions = {}; | ||
| #pageLifecycle: ReturnType<typeof createPageLifecycle> | null = null; | ||
| #touchThrottledUntil = 0; | ||
| #offlineScheduler = createOfflineScheduler(); |
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.
It's not immediately clear that this de-dupes all calls to .schedule() when offline, regardless of what function is provided. Should this be called sessionTouchOfflineScheduler maybe? I wouldn't want someone finding this and using it elsewhere if they aren't aware of this behavior.
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 see, yeah we can change the name.
|
Update on this:
We will be addressing the bug of broadcasting sign out on another PR. We are already investigating issues with our sign out mechanism and there is no reason to delay the release of this PR. |
Description
Pause session touch when browser is offline, and resume it when the device comes back online. When it is back online it will call
touchonce.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change