Skip to content

fix: pass gracedEntry to background factories - #124

Open
JacobLey wants to merge 1 commit into
Julien-R44:mainfrom
JacobLey:fix/graced-entry-in-background-factory
Open

JacobLey wants to merge 1 commit into
Julien-R44:mainfrom
JacobLey:fix/graced-entry-in-background-factory

Conversation

@JacobLey

Copy link
Copy Markdown

Existing issue

With grace enabled and the default timeout: 0, a stale value is refreshed in the background, and that factory always gets gracedEntry: undefined. Only the foreground path passes the graced value (FactoryRunner.run(), the shouldSwr branch calls #runFactory without gracedValue).

timeout: 0 is the default, so this is the common stale-while-revalidate path. The docs present gracedEntry as available whenever a graced value exists. A factory can't tell it is only refreshing (e.g. to keep the stale value rather than refetch, or skip work another process is already doing).

Proposed fix

pass gracedValue in the background branch too.

Testing context

It appears the existing can access graced entry asserts inside the factory, which runs in the background under the default timeout. The failing assertion is thrown in the background and swallowed, and assert.plan(2) still counts it, so the test passes with or without the fix. The new test asserts outside the factory, and fails without the fix.

Typecheck and eslint pass.

Proposed patch for version bumping

@changeset-bot

changeset-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

馃 Changeset detected

Latest commit: 1e67fa9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
bentocache Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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