Skip to content

javascript Bug: Error state expiration check is inverted, preventing SDK recovery after 10 minutes #7190

Closed as not planned

Description

@tomikawa-san

Issue Summary

The error state expiration logic in packages/js-core/src/lib/common/setup.ts has an inverted condition. When an error occurs, the SDK sets a 10-minute expiration time, but:

  • Within 10 minutes: SDK retries initialization (should skip to reduce server load)
  • After 10 minutes: SDK permanently skips initialization (should retry to recover)

This means once 10 minutes pass, the SDK never recovers unless users manually clear localStorage.

Test Results:

Within 10 minutes:

🧱 Formbricks - Error state is expired. Continuing with initialization.

After 10 minutes:

🧱 Formbricks - Error state is not expired, skipping initialization.

The condition and log messages are completely inverted.

Expected Behavior

Within 10 minutes of error:

  • Skip initialization to avoid overwhelming the server
  • Log: "Error state is not expired, skipping initialization"

After 10 minutes:

  • Retry initialization to attempt recovery
  • Log: "Error state is expired. Continuing with initialization"

Other information (incl. screenshots, Formbricks version, steps to reproduce,...)

Current behavior (inverted):

Within 10 minutes:

  • Retries initialization (creates unnecessary server load)
  • Logs: "Error state is expired. Continuing with initialization."

After 10 minutes:

  • Permanently skips initialization (SDK never recovers)
  • Logs: "Error state is not expired, skipping initialization"

Code location:
packages/js-core/src/lib/common/setup.ts lines 119-123

if (expiresAt && isNowExpired(new Date(expiresAt))) {
  // When isNowExpired returns true (expired), it skips - INVERTED!
  console.error("🧱 Formbricks - Error state is not expired, skipping initialization");
  return okVoid();
}
console.error("🧱 Formbricks - Error state is expired. Continuing with initialization.");


### Your Environment

Self-hosted Formbricks

Activity

  1. added
    bug
    on Feb 2, 2026
  2. added theissue type on Feb 2, 2026
  3. bharathkumar39293 commented on Feb 4, 2026

    @bharathkumar39293
    Contributor

    I’ve opened a PR that fixes the inverted expiration logic and adds test coverage: #7202
    Happy to adjust if anything needs tweaking. @jobenjada

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions