Repository navigation
Conversation
Backport of #9871. Keep expire_at and abandon_at of 0 as Unix epoch zero for Session and SessionWithActivities instead of substituting the current time, so sessions without a maximum lifetime survive loading and snapshot restoration. The shared unixEpochToDate helper is unchanged for non-session callers.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 3863df0 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 |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
…zero-session-deadlines
…rces Session and SessionWithActivities expose hasMaximumLifetime, false when expireAt is Unix epoch zero. The SessionResource and SessionWithActivitiesResource types gain the optional property with the same documentation as Core 3. Bump clerk-js, shared and types as minor, and drop the comment above unixEpochToSessionDeadline. Part of MOBILE-517
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
…ources Remove hasMaximumLifetime from Session, SessionWithActivities and their resource types. Session expireAt and abandonAt still stay at Unix epoch zero for sessions without a maximum lifetime, and the changeset is now a clerk-js patch for that fix. Part of MOBILE-517
dmoerner
left a comment
There was a problem hiding this comment.
A few nits:
- Let's bring this as close as possible to the Core 3 PR: Use the same helper name
unixEpochToDeadlineso we can cherry-pick fixes easily if necessary. I think the description is also stale, it looks like the last commit on #9871 changed it to use the same helper design. - With this helper we are now supposedly passing milliseconds into a helper that takes seconds. However, I think the helper always took milliseconds and the name was incorrect. We shouldn't change this in the code now but we can document it in the PR description.
- As we discussed I think we should just test this E2E with a Core 2 app, Claude can do it.
- Just a reminder that I think we need to deploy this to the infra workers to hotload it before we ship. Last time we had to ship a Core 2 fix there was actually some sort of bottleneck figuring out who even had permissions to do it, but I think Bryce probably does and he was just OOO then.
Rename unixEpochToSessionDeadline to unixEpochToDeadline and use the same helper, tests and session fallback test as Core 3 main, so later fixes cherry-pick cleanly. Part of MOBILE-517
Description
Backport of #9871 to Core 2 (ClerkJS 5.x).
Native sessions can have no maximum lifetime (MOBILE-517). FAPI sends a missing deadline as
expire_at: 0/abandon_at: 0. On Core 2,unixEpochToDatetreats0as falsy and substitutes the current time. A session without a maximum lifetime therefore loaded withexpireAtandabandonAtset to "now".__internal_toSnapshot()then wrote that time back out, so a restored client carried a fabricated finite deadline.This change keeps Unix epoch zero for session deadlines only, using the same helper as Core 3:
unixEpochToDeadlineinutils/date.tsreturnsnew Date(0)for0and otherwise defers tounixEpochToDate. Its name, signature, body and tests match Core 3main, so later fixes cherry-pick cleanly.SessionandSessionWithActivitiesuse it forexpire_atandabandon_at. Snapshots already serializegetTime(), so zero now round-trips.unixEpochToDateis unchanged, so every other date field still falls back to the current time for0, as before.There is no
hasMaximumLifetimeproperty; it was dropped from both Core 2 and Core 3. This is a patch fix for@clerk/clerk-js. It adds no public API.unixEpochToDate(epochInSeconds)has always received millisecond timestamps from every caller, despite its parameter name. This PR deliberately leaves that name alone.Release this before enabling the backend
native_session_lifetimespolicy (clerk/clerk_go#22369) for instances that may run Core 2 SDKs. The rollout contract requires compatible SDKs before the flag is turned on.Part of MOBILE-517. Core 3 fix: #9871 and #10364. Backend: clerk/clerk_go#22459, clerk/clerk_go#22460, clerk/clerk_go#22461, clerk/clerk_go#22462, clerk/clerk_go#22369.
Checklist
pnpm testruns as expected.@clerk/shared,@clerk/clerk-js, and@clerk/clerk-expounit tests passed; full monorepo suite not run.pnpm buildruns as expected.@clerk/shared,@clerk/clerk-js,@clerk/clerk-expo, and@clerk/chrome-extensionbuilt; full monorepo build not run.Type of change
End to end on a Core 2 Expo app
I ran a Core 2 app against a local clerk_go stack that sends real zero deadlines:
sam/mobile-session-lifetimes, the top of the native-lifetime stack, run withmake up/demoplus the Platform API. I created a development instance through PLAPI, turned onnative_session_lifetimesfor it, and savednative_maximum_lifetime: {"enabled": false, "duration_seconds": 0}throughPATCH …/config. A native password sign-in (_is_native=1) to that instance returnsexpire_at: 0andabandon_at: 0.The app is a blank Expo SDK 58 app running in Expo Go on an iOS 26 simulator (iPhone 17 Pro). It uses
@clerk/clerk-expo@2.20.2withtokenCacheand__experimental_resourceCache, so the client snapshot is saved to SecureStore and restored when FAPI can't be reached. The screen shows the session'sexpireAt/abandonAtand the rawexpire_at/abandon_atfrom the cached snapshot. Only@clerk/clerk-jsdiffers between the runs:@clerk/clerk-js@5.128.1from npm.@clerk/clerk-jspacked from this branch. Its build matches headc393468f08at runtime; the one source difference is a deleted comment.Each run signs in, then relaunches the app with the local nginx (FAPI) stopped. That relaunch makes ClerkJS restore the cached snapshot (
clerk.statusdegraded).activein every state, and ClerkJS loads normally from FAPI.The app, the local instance and the test user (
+clerk_testemail, generated password) exist only on my machine. Nothing ran against a hosted Clerk instance.