# @effectionx/timebox

> Constrain operations to complete within a time limit

Latest version **0.4.3** (published 2026-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @effectionx/timebox
pnpm add @effectionx/timebox
yarn add @effectionx/timebox
bun add @effectionx/timebox
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.4.3 |
| Published | 2026-03-22 |
| First published | 2025-04-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 61.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 12 |
| Author | engineering@frontside.com |
| Maintainers | frontsidejack |
| Keywords | effection, effectionx, concurrency, timeout, deadline |

## Links

- npm: https://www.npmjs.com/package/@effectionx/timebox
- Repository: https://github.com/thefrontside/effectionx
- Homepage: https://github.com/thefrontside/effectionx#readme
- Issues: https://github.com/thefrontside/effectionx/issues
- npm.io page: https://npm.io/package/@effectionx/timebox

## Recent versions

- 0.4.3 (latest) — 2026-03-22
- 0.4.2 — 2026-02-23
- 0.4.1 — 2026-02-12
- 0.4.0 — 2026-01-18
- 0.3.1 — 2025-12-08
- 0.3.0 — 2025-12-08
- 0.1.0 — 2025-10-19
- 0.2.0 — 2025-08-22
- 0.1.2 — 2025-08-08
- 0.1.1 — 2025-04-10

## README

# Timebox

Constrain any operation to complete within a certain time.

---

Very often you want to put a limit on how long an operation may run such as a
`fetch()` of an external resource, or handling a web request. To do this, you
can use the `timebox()` function. It will encapsulate the operation and either
return its result, or a otherwise a "timeout" object indicating that it did not
complete in the required time.

```ts
import { timebox } from "@effectionx/timebox";
import { handleRequest } from "./handle-request";

// a theoretical request handler
export function* handler(request) {
  // do not let the handler run for more than 10 seconds
  let result = yield* timebox(10000, () => handleRequest(request));
  if (result.timeout) {
    return new Response(504, "Gateway Timeout");
  } else {
    return result.value;
  }
}
```

---
_Source: https://npm.io/package/@effectionx/timebox · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
