Skip to content

[codex] Add timeout option helper#65

Merged
samlaycock merged 2 commits into
mainfrom
codex/timeout-option-helper
May 19, 2026
Merged

[codex] Add timeout option helper#65
samlaycock merged 2 commits into
mainfrom
codex/timeout-option-helper

Conversation

@samlaycock

Copy link
Copy Markdown
Owner

Summary

Adds fx.timeoutOption for timeout-as-value boundary workflows without changing existing fx.timeout semantics. The helper delegates to Effect's timeoutOption, returning Option.some(value) when the task completes in time and Option.none() when the timeout wins while preserving original task errors and dependency requirements.

Closes #54.

Changes

  • Expose fx.timeoutOption from the public fx API.
  • Add runtime tests for slow and fast tasks.
  • Add type-level tests for success, error, and dependency inference.
  • Document when to use fx.timeoutOption versus fx.timeout and fx.timeoutFail.
  • Add a changeset for the new helper.

Validation

  • bun fmt
  • bun lint:fix
  • bun lint
  • bun test
  • bun typecheck

Expose fx.timeoutOption as a timeout-as-value helper over Effect.timeoutOption.

Add runtime coverage for fast and slow task behavior, type-level coverage for result/error/dependency inference, and document when to prefer the helper over fx.timeout or fx.timeoutFail.
@samlaycock samlaycock marked this pull request as ready for review May 19, 2026 20:08
@greptile-apps

greptile-apps Bot commented May 19, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds fx.timeoutOption, a thin wrapper around Effect's timeoutOption that returns Option.some(value) on success and Option.none() on timeout, preserving original errors and dependencies. It follows the same pattern as timeoutFail and is a clean, additive change.

  • src/concurrency.ts: New timeoutOption helper with explicit return type and proper Option import; delegated to Effect.timeoutOption.
  • Tests cover both the runtime behavior (slow/fast tasks) and type-level inference (result, error, dependency).
  • Docs and changeset are updated consistently with the rest of the module.

Confidence Score: 5/5

Purely additive helper with no changes to existing behavior; safe to merge.

The change is a small, isolated addition that delegates directly to a well-tested Effect primitive. All existing exports are untouched, the return type is explicitly annotated, both runtime and type-level tests are present, and docs plus a changeset are included.

No files require special attention.

Important Files Changed

Filename Overview
src/concurrency.ts Adds timeoutOption helper with explicit return type, Option import, and correct delegation to Effect.timeoutOption.
src/index.ts Exports timeoutOption from the public fx object alongside the other timeout helpers.
test/runtime.test.ts Adds two runtime tests for the slow (None) and fast (Some) paths of fx.timeoutOption.
test/types.test.ts Adds type-level tests verifying result, error, and dependency inference for fx.timeoutOption.
docs/retry-timeout.md Adds documentation for fx.timeoutOption with usage guidance and comparison to fx.timeout/fx.timeoutFail.
docs/api-reference.md Adds fx.timeoutOption entry to the API reference table.
.changeset/timeout-option-helper.md Correct minor-version changeset for the new public helper.

Reviews (2): Last reviewed commit: "fix: declare timeout option return type" | Re-trigger Greptile

Comment thread src/concurrency.ts Outdated
Import Option and annotate fx.timeoutOption with its public Task<Option.Option<A>, E, R> contract.

This matches the exported helper style used throughout the concurrency module and addresses the PR review feedback.
@samlaycock samlaycock merged commit 51e804b into main May 19, 2026
2 checks passed
@samlaycock samlaycock deleted the codex/timeout-option-helper branch May 19, 2026 20:19
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.

P2: Add timeout-as-value helper for common boundary workflows

1 participant