Skip to content

fix(js-core): invert expiration logic for SDK error state (#7190) - #7202

Merged
Dhruwang merged 2 commits into
formbricks:mainfrom
bharathkumar39293:fix/7190-sdk-error-state-inversion
Feb 9, 2026
Merged

Dhruwang merged 2 commits into
formbricks:mainfrom
bharathkumar39293:fix/7190-sdk-error-state-inversion

Conversation

@bharathkumar39293

Copy link
Copy Markdown
Contributor

This PR fixes an inverted error backoff check in the JS SDK that prevented recovery after the 10-minute cooldown period.

Problem

The SDK was retrying initialization during the active error backoff window and permanently skipping initialization once the window expired. This caused the SDK to never recover unless users manually cleared localStorage.

Fix

Corrected the expiration check in setup.ts so that:

Initialization is skipped while the error state is active (not expired)

Initialization is retried once the error state expires

Updated console log messages to reflect the corrected behavior

Tests

Updated existing test to verify setup is skipped when the error state is active

Added a test to verify setup continues once the error state is expired

Verification

Unit tests passed:

pnpm turbo run test --filter=@formbricks/js-core

Manually verified via localStorage timestamp manipulation as described in #7190

This restores the intended backoff + recovery behavior without any API or storage changes.

@CLAassistant

CLAassistant commented Feb 4, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The changes modify the initialization logic in setup.ts to invert the condition checking expiration state. Previously, initialization was skipped when an error state was expired. The new logic skips initialization only when the error state has not yet expired. The test file was updated to import getIsDebug and add test coverage for both expired and non-expired error states, including verification that initialization proceeds when the error state expires and is skipped when it has not yet expired. Debug mode handling was also introduced in the tests.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description covers the problem, fix, tests, and verification. However, the 'How should this be tested?' section and most required checklist items are missing or unchecked. Complete the 'How should this be tested?' section with detailed testing steps and fill out the required checklist items.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: inverting the expiration logic for SDK error state, which is the core fix addressed in the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • ✨ 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist.


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.

@bharathkumar39293

Copy link
Copy Markdown
Contributor Author

@mattinannt 👋
This PR fixes the inverted error-state expiration logic from #7190 and restores proper SDK recovery after the cooldown period.

Tests are updated and passing, and I’ve manually verified the behavior.
Could you please review when you have a moment?

@Dhruwang Dhruwang mentioned this pull request Feb 9, 2026
12 tasks

@Dhruwang Dhruwang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, looks good ! 🚀

@Dhruwang
Dhruwang added this pull request to the merge queue Feb 9, 2026
Merged via the queue into formbricks:main with commit 13b9db9 Feb 9, 2026
19 of 23 checks passed
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.

3 participants