Skip to content

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

Description

@MartinRamm

What version of Effect is running?

3.21.4

What steps can reproduce the bug?

Run the following code:

import { Effect, pipe } from 'effect';

const causeTimeout = pipe(
  Effect.async(() => {}),
  Effect.timeoutFail({
    duration: '1 second',
    onTimeout: () => 'Timeout',
  })
);

await pipe(
  Effect.cachedWithTTL(causeTimeout, '1 minute'),
  Effect.andThen(run => run),
  Effect.runPromiseExit,
  promiseExit => Promise.race([
    promiseExit,
    new Promise((resolve) => setTimeout(() => resolve('Timeout waiting for Exit'), 5_000))
  ]).then(console.log)
);

What is the expected behavior?

A Exit object with failure "Timeout" is printed to the console

What do you see instead?

String "Timeout waiting for Exit" is printed to console

Additional information

It seems like Effect.cachedWithTTL prevents the timeout from being triggered. Interestingly enough, Effect.cached works as expected.

Effect.cachedInvalidateWithTTL also suppresses to trigger the timeout

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.0Used for issues, pull requests, etc. that are relevant for the `v3` branch targeting Effect v3.bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions