Skip to content

Refresh in-memory Client after sign-out and add tests#587

Open
swolfand wants to merge 1 commit intomainfrom
codex/review-android-expo-changes-for-sdk-integration
Open

Refresh in-memory Client after sign-out and add tests#587
swolfand wants to merge 1 commit intomainfrom
codex/review-android-expo-changes-for-sdk-integration

Conversation

@swolfand
Copy link
Copy Markdown
Collaborator

@swolfand swolfand commented Apr 9, 2026

Motivation

  • Ensure stale in-progress sign-in/sign-up state does not persist after sign-out by refreshing the in-memory Client while skipping the current client id.

Description

  • Add a best-effort client refresh in SignOutService.signOut() by invoking Client.getSkippingClientId() inside the finally block and logging failures.
  • Import Client and perform the refresh via runCatching { Client.getSkippingClientId() } to avoid breaking sign-out flow on refresh errors.
  • Extend tests to mock ClerkApi.client and ClientApi.getSkippingClientId() and update existing sign-out tests to include the client refresh expectation.
  • Add two new tests: signOut refreshes client after local sign-out cleanup and signOut tolerates client refresh failure which verify the client refresh is called and that refresh failures are tolerated.

Testing

  • Ran the SignOutServiceTest suite including the two new tests signOut refreshes client after local sign-out cleanup and signOut tolerates client refresh failure, and all tests passed.
  • Existing tests that verify device token deletion and session/user clearing were updated to mock ClientApi.getSkippingClientId() and passed successfully.
  • Verified that SignOutService.signOut() returns ClerkResult.Success on normal flows and still clears local state when server sign-out or client refresh fails.

Codex Task

Perform a best-effort Client.getSkippingClientId() refresh after local sign-out cleanup so stale in-progress sign-in/sign-up state does not persist across remounts.\n\nAlso expands SignOutService tests to mock ClientApi and assert the refresh call occurs and failures are tolerated.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a22cb7a3-801d-435a-ba32-fdd1c4133426

📥 Commits

Reviewing files that changed from the base of the PR and between 1580bc7 and 98f7811.

📒 Files selected for processing (2)
  • source/api/src/main/kotlin/com/clerk/api/signout/SignOutService.kt
  • source/api/src/test/java/com/clerk/api/signout/SignOutServiceTest.kt

📝 Walkthrough

Walkthrough

This change adds a best-effort client state refresh to the sign-out flow. After the existing local sign-out cleanup (token deletion and session/user state clearing), the code now attempts to call Client.getSkippingClientId() to refresh in-memory client data while skipping the current client ID. The refresh is wrapped in error handling that logs warnings on failure. The existing sign-out logic and return behavior remain unchanged. Corresponding test coverage was added to verify the new client refresh is invoked and handles failure gracefully.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main changes: refreshing the in-memory Client after sign-out and adding corresponding tests.
Description check ✅ Passed The description includes motivation, implementation details, testing approach, and test results, comprehensively covering the changes despite the template requiring only a 'Summary of changes' section.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant