Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/middleware/builtin/timeout.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ app.get('/api/long-process', async (c) => {
})
```

::: tip Fresh error stacks

Use a factory when timeout errors are reported to an observability service:

```ts
timeout(
5000,
() => new HTTPException(504, { message: 'Gateway Timeout' })
)
```

Passing an exception instance reuses its construction-time stack for every timeout, which can affect stack attribution and error fingerprinting.

:::

## Notes

- The duration for the timeout can be specified in milliseconds. The middleware will automatically reject the promise and potentially throw an error if the specified duration is exceeded.
Expand Down