alepha@docs:~/docs/reference/primitives$
cat $timeout.md
1 min read

#$timeout

#Import

typescript
1import { $timeout } from "alepha/datetime";

#Overview

Middleware that aborts handler execution if it exceeds a duration limit.

Uses Promise.race with a managed timeout from DateTimeProvider — if the handler doesn't resolve before the deadline, the promise rejects. Uses managed timeouts so it works with DateTimeProvider.travel() in tests.

typescript
1class OrderService {2  processOrder = $pipeline({3    use: [$timeout([30, "seconds"])],4    handler: async (orderId: string) => {5      return await this.orders.updateById(orderId, { status: "paid" });6    },7  });8}