Skip to content

Conversation

stnguyen90
Copy link
Contributor

@stnguyen90 stnguyen90 commented Oct 10, 2025

What does this PR do?

At the moment, if a cookie isn't set, only the local storage cookie fallback is used for realtime authentication. This means sessions using client.setSession() will be unauthenticated when using realtime.

This PR makes realtime use this.config.session (which is set with client.setSession()) if it exists.

Test Plan

This needs to be tested still.

Related PRs and Issues

Have you read the Contributing Guidelines on issues?

None

Summary by CodeRabbit

  • Bug Fixes
    • Authentication now prioritizes the configured session when available, only falling back to cookies if needed. This yields more reliable sign-ins, fewer session mismatches, and reduced unexpected logouts—especially in environments with restricted or cleared cookies. Users should experience more consistent session continuity during reconnects, with no changes required to existing workflows.

At the moment, if a cookie isn't set, only the local storage cookie fallback is used for realtime authentication. This means sessions using client.setSession() will be unauthenticated when using realtime.

This PR makes realtime use this.config.session (which is set with client.setSession()) if it exists.
Copy link
Contributor

coderabbitai bot commented Oct 10, 2025

Walkthrough

The change updates session resolution during the "connected" onMessage handling to prefer this.config.session and fallback to cookieFallback only if absent. The authentication payload now uses the resolved session from config when available. Retrieval of messageData remains unchanged. No alterations were made to the structure of the authentication request beyond the session source, and no exported or public entity declarations were modified.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the main change—enabling realtime to use the session provided by setSession()—and aligns directly with the modifications in the pull request without unnecessary detail or ambiguity.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-8925-realtime-session-web-sdk

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1f9097 and 2eb9b58.

📒 Files selected for processing (1)
  • templates/web/src/client.ts.twig (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
  • GitHub Check: swift (server)
  • GitHub Check: ruby (server)
  • GitHub Check: react-native (client)
  • GitHub Check: android (client)
  • GitHub Check: flutter (client)
  • GitHub Check: web (client)
  • GitHub Check: build (8.3, PHP80)
  • GitHub Check: build (8.3, WebChromium)
  • GitHub Check: build (8.3, WebNode)
  • GitHub Check: build (8.3, KotlinJava8)
  • GitHub Check: build (8.3, Python313)
  • GitHub Check: build (8.3, DotNet90)
  • GitHub Check: build (8.3, AppleSwift56)
  • GitHub Check: build (8.3, FlutterBeta)
  • GitHub Check: build (8.3, FlutterStable)
  • GitHub Check: build (8.3, DartStable)
  • GitHub Check: build (8.3, Android5Java17)
  • GitHub Check: build (8.3, Android14Java17)
🔇 Additional comments (1)
templates/web/src/client.ts.twig (1)

481-487: Logic change correctly prioritizes config.session over localStorage fallback.

  • Confirm that this.config.session is defined and correctly typed in the generated config interface.
  • Confirm that a setSession() method exists and assigns to config.session.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant