Skip to content

fix(flags): skip flag revalidation when evaluation is disabled or pending - #1095

Merged
izadoesdev merged 3 commits into
databuddy-analytics:stagingfrom
mvanhorn:fix/1091-sdk-flags-skip-inactive-revalidation
Oct 17, 2026
Merged

izadoesdev merged 3 commits into
databuddy-analytics:stagingfrom
mvanhorn:fix/1091-sdk-flags-skip-inactive-revalidation

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Oct 7, 2026 •

Copy link
Copy Markdown

Description

isEnabled() and getValue() now require evaluation to be active before revalidating a stale entry or fetching a cache miss. Cached results and overrides are still returned immediately, and a miss still returns the existing loading or fallback value. Active stale reads still revalidate. Server flags tests cover disabled and pending stale reads, inactive cache misses, overrides while disabled, and an active stale read, and a patch changeset records the skip.

After a flag is cached, synchronous isEnabled() and getValue() reads still start a background evaluation once that entry is stale, including when the manager is disabled or the session is still pending. The caller keeps receiving the cached flag while an extra evaluation request goes out. On a stale cache hit, both methods call revalidate() when the entry is stale and shouldSkipFetch() is false. On a cache miss, they start a background getFlag() when canFetchOnRead() is true. Neither branch checks config.disabled or config.isPending.

Closes #1091

Slice

  • Issue: #
  • Scope / owning surface:
  • Dependencies or overlapping PRs: None
Checklist
  • This branch started from current staging and does not include another unmerged PR unless it is named above.
    Not claimed: npm test could not run in this environment (dotenv is not installed).
  • This is one independently reviewable slice; unrelated cleanup or refactors are in separate PRs.
  • I checked open PRs for overlapping files, contracts, schemas, or deployment configuration and made any dependency explicit above.
  • This PR targets staging; after it closes, this branch will not be reused for another change.
    Not claimed: staging was not run locally either.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
    Not claimed: the same reason as the box above applies.

AI disclosure

AI was used for assistance.

  • Tools: Cursor.

Summary by cubic

isEnabled() and getValue() skip background flag revalidation when evaluation is disabled or the session is pending, so stale cached flags no longer trigger unnecessary network requests.

  • The guard is consolidated into a single check inside revalidate().
  • Cached results and overrides still return immediately; active stale reads still revalidate.
  • Adds separate server tests for disabled and pending stale reads sharing a helper, covering isEnabled() and getValue() on separate managers.
  • Adds a patch changeset.

Fixes #1091.

Written for commit b75cff9. Summary will update on new commits.

View guided diff

@mvanhorn
mvanhorn requested a review from izadoesdev as a code owner October 7, 2026 07:25
@vercel

vercel Bot commented Oct 7, 2026

Copy link
Copy Markdown

@mvanhorn is attempting to deploy a commit to the Databuddy OSS Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: ae892bd0-5624-4653-abb6-33b986fe078f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • 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

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

@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Stops background flag refreshes while evaluation is disabled or waiting for a session.

  • Stale flag reads skip refreshes while evaluation is inactive.

No new actionable issues found. Tests were not run.

Reviews (2) · Last reviewed commit: "fix(sdk): guard stale flag revalidation ..." · Reviewed by Greptile

Comment thread packages/sdk/tests/server-flags-manager.test.ts Outdated
Comment thread packages/sdk/tests/server-flags-manager.test.ts Outdated
mvanhorn and others added 3 commits October 17, 2026 16:40
…ding

isEnabled() and getValue() now require evaluation to be active before
revalidating a stale entry or fetching a cache miss. Cached results and
overrides are still returned immediately, and a miss still returns the
existing loading or fallback value. Active stale reads still revalidate.
Server flags tests cover disabled and pending stale reads, inactive
cache misses, overrides while disabled, and an active stale read, and a
patch changeset records the skip.

Fixes databuddy-analytics#1091
Run the disabled and pending stale-read cases as separate tests sharing a
helper instead of awaiting inside a loop, and test isEnabled() and
getValue() revalidation on separate managers so each asserts its own
refresh request for the stale key.
@izadoesdev
izadoesdev force-pushed the fix/1091-sdk-flags-skip-inactive-revalidation branch from 23907c0 to b75cff9 Compare October 17, 2026 17:52
@izadoesdev
izadoesdev changed the base branch from main to staging October 17, 2026 17:52
@izadoesdev izadoesdev closed this Oct 17, 2026
@izadoesdev izadoesdev reopened this Oct 17, 2026
@izadoesdev
izadoesdev merged commit 7032cfa into databuddy-analytics:staging Oct 17, 2026
9 of 12 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.

SDK cached reads still revalidate when evaluation is disabled or pending

2 participants