Skip to content

fix: finish setup when the /user sync fails, keeping the saved user [ENG-7681] - #94

Open
pandeymangg wants to merge 2 commits into
mainfrom
anshuman/eng-7681-react-native-a-failed-user-sync-at-setup
Open

pandeymangg wants to merge 2 commits into
mainfrom
anshuman/eng-7681-react-native-a-failed-user-sync-at-setup

Conversation

@pandeymangg

Copy link
Copy Markdown
Contributor

Fixes ENG-7681

What & why

Since ENG-7265 (#93, on main, not released), setup really syncs /user when the saved user state has expired. If that call failed, setup returned early: no config saved, no timers, no error state. <Formbricks /> ignores the error, so every track was dropped until the app restarted.

Now a failed sync logs the error, keeps the saved user, pushes its expiry 30 min ahead and finishes setup. This is the agreed behaviour for all five SDKs (ENG-7620 #9). syncUserStateIfExpired no longer returns a Result, since it can't fail any more.

  • Door: two-way. Internal logic only, no public API change (pnpm api:check passes).
  • Blast radius: RN setup, only when a saved user with a userId has expired and /user fails.

Tests (red on main, green here)

Test On main
setup.test.ts › finishes setup with the saved user when the user sync fails, so track can show a survey ❌ expected false to be true on result.ok

The old test "returns an error when user sync fails" asserted the bug and is removed. The ENG-7265 back-off tests pass unchanged.

Lint, format, types, 231/231 tests, build, api:check, script tests and package-check pass locally.

…ENG-7681]

A failed /user sync at setup returned early, so setup never finished and every track was dropped until the app restarted. Keep the saved user state, push its expiry 30 minutes ahead and finish setup (ENG-7620 #9).
@sonarqubecloud

sonarqubecloud Bot commented Dec 4, 2026

Copy link
Copy Markdown

@pandeymangg
pandeymangg marked this pull request as ready for review December 4, 2026 10:16
@coderabbitai

coderabbitai Bot commented Dec 4, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

User-state synchronization now returns a user state directly. When synchronization fails, the saved state is retained with its expiry advanced by 30 minutes, and setup continues without returning a user-sync error. Tests cover failed synchronization, unexpired saved state, missing user IDs, and survey selection after tracking an action.

Merge Risk: Minimal · up to 3118a

Setup now finishes with the saved user when the user sync request fails, so surveys can still be shown. No actionable merge risk was identified; the only failing CI job is an e2e tunnel provisioning problem unrelated to this change.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: setup now finishes when the /user sync fails, and the saved user is kept. It matches the raw summary, which says setup no longer propagates user-sync errors and keeps …
Description check Passed The description states the bug, the fix, the affected scope (RN setup when an expired saved user with a userId has its /user call fail), the test changes, and the local checks run. It matches the chan…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: setup now finishes when the /user sync fails, and the saved user is kept. It matches the raw summary, which says setup no longer propagates user-sync errors and keeps the saved user with its expiry advanced by 30 minutes. The title also names the fix type and ticket.

Full details: Description check

Explanation

The description states the bug, the fix, the affected scope (RN setup when an expired saved user with a userId has its /user call fail), the test changes, and the local checks run. It matches the changes in setup.ts and setup.test.ts.

Finishing Touches

Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 8298c57f-12f5-4736-9fd2-5cbd871a741c
Commits

Reviewing files that changed from the base of the PR and between e9b914b and 3118afb.

Files selected for processing: 2

  • packages/react-native/src/lib/common/setup.ts
  • packages/react-native/src/lib/common/tests/setup.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

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