Skip to content

fix: prevent cachedWithTTL from suppressing interruption of the cached effect#6316

Open
xianjianlf2 wants to merge 1 commit into
Effect-TS:v3from
xianjianlf2:fix/cachedwithttl-suppresses-interrupt-6304
Open

fix: prevent cachedWithTTL from suppressing interruption of the cached effect#6316
xianjianlf2 wants to merge 1 commit into
Effect-TS:v3from
xianjianlf2:fix/cachedwithttl-suppresses-interrupt-6304

Conversation

@xianjianlf2

Copy link
Copy Markdown

Closes #6304

Effect.cachedWithTTL / Effect.cachedInvalidateWithTTL run the cached effect uninterruptibly: getCachedValue wraps populate-and-await in core.uninterruptibleMask, and computeCachedValue runs the user effect via core.intoDeferred(self, deferred) under that mask — so interruption-based combinators like Effect.timeout can never fire and the fiber hangs. (Effect.cached is unaffected because it maps to effect.memoize, a different path.)

The mask's restore was only applied to deferredAwait, not to running self. This threads restore into computeCachedValue and applies it to the cached effect:

-      core.intoDeferred(self, deferred)
+      core.intoDeferred(restore(self), deferred)
  • Added it.live tests for both combinators asserting a timed-out cached effect yields Exit.fail("Timeout"); without the fix they hang ~15s and fail.
  • pnpm test run test/Effect/caching.test.ts → 5 passed; pnpm --filter=effect check clean. Changeset included.

…he cached effect

Effect.cachedWithTTL and Effect.cachedInvalidateWithTTL ran the cached
effect inside getCachedValue's uninterruptibleMask while populating the
cache, which suppressed interruption-based combinators such as
Effect.timeout. Restore the caller's interruptibility around the cached
effect so it can be interrupted, matching the non-cached behaviour.

Closes Effect-TS#6304
@xianjianlf2 xianjianlf2 requested a review from mikearnaldi as a code owner July 11, 2026 10:47
@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jul 11, 2026
@changeset-bot

changeset-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 467b8d1

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

This PR includes changesets to release 1 package
Name Type
effect 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

@IMax153 IMax153 changed the base branch from main to v3 July 13, 2026 23:55
@IMax153 IMax153 added the 3.0 Used for issues, pull requests, etc. that are relevant for the `v3` branch targeting Effect v3. label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.0 Used for issues, pull requests, etc. that are relevant for the `v3` branch targeting Effect v3.

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

Effect.cachedWithTTL and Effect.cachedInvalidateWithTTL suppress triggering of Effect.timeout

2 participants