Refactor managed relay session to idiomatic Effect#3506
Closed
cursor[bot] wants to merge 4 commits into
Closed
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
Option<string>from an Effect-native provider instead ofstring | nulland a local Promise cache.Schema.TaggedErrorClasserrors and switched relay timing constants toDuration.Why
This keeps the managed relay session core in Effect end-to-end: cache reuse, concurrent read deduplication, provider refresh, and expiry behavior are now testable with Effect primitives instead of Promise coordination and nullable values.
UI Changes
No UI changes.
Checklist
Validation:
PATH="/home/ubuntu/.nvm/versions/node/v24.17.0/bin:$PATH" pnpm run test -- src/relay/managedRelayState.test.tsfrompackages/client-runtimePATH="/home/ubuntu/.nvm/versions/node/v24.17.0/bin:$PATH" pnpm run test -- src/cloud/managedAuth.test.tsfromapps/webPATH="/home/ubuntu/.nvm/versions/node/v24.17.0/bin:$PATH" pnpm exec vp checkPATH="/home/ubuntu/.nvm/versions/node/v24.17.0/bin:$PATH" pnpm exec vp run typecheckPATH="/home/ubuntu/.nvm/versions/node/v24.17.0/bin:$PATH" pnpm exec vp run lint:mobileNote
Refactor managed relay session token handling to use Effect and Option types
Promise<string|null>withEffect<Option<string>, ManagedRelaySessionError>forreadClerkTokenacrossmanagedRelayState.ts,managedAuth.tsx, andCloudAuthProvider.tsx.ManagedRelaySessionTokenReadErrorandManagedRelaySessionTokenUnavailableErroras tagged Schema error classes, replacing generic errors for missing session and missing token cases.createManagedRelaySessionto deduplicate concurrent reads viaDeferred, cache tokens until JWT expiry (with a 5s skew), and propagate provider errors through the typed error union.Duration-based constants (DEFAULT_STALE_TIME,DEFAULT_IDLE_TTL,CLERK_TOKEN_EXPIRY_SKEW) inmanagedRelayState.ts.setManagedRelaySessionmust now providereadClerkTokenas anEffectreturningOption<string>rather than aPromise<string|null>.Macroscope summarized 6ebcdda.