# nice-grpc-client-middleware-deadline

> Deadline client middleware for nice-grpc

Latest version **2.0.20** (published 2026-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install nice-grpc-client-middleware-deadline
pnpm add nice-grpc-client-middleware-deadline
yarn add nice-grpc-client-middleware-deadline
bun add nice-grpc-client-middleware-deadline
```

## Health

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

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.0.20 |
| Published | 2026-08-04 |
| First published | 2021-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 540 |
| Author | Daniel Lytkin <aikoven@deeplay.io> |
| Maintainers | aikoven |

## Links

- npm: https://www.npmjs.com/package/nice-grpc-client-middleware-deadline
- Repository: https://github.com/deeplay-io/nice-grpc
- Homepage: https://github.com/deeplay-io/nice-grpc/tree/master/packages/nice-grpc-client-middleware-deadline#readme
- Issues: https://github.com/deeplay-io/nice-grpc/issues
- npm.io page: https://npm.io/package/nice-grpc-client-middleware-deadline

## Dependencies (1)

- [nice-grpc-common](https://npm.io/package/nice-grpc-common.md) ^2.0.4

## Recent versions

- 2.0.20 (latest) — 2026-08-04
- 2.0.19 — 2026-04-24
- 2.0.18 — 2026-04-12
- 2.0.17 — 2025-11-12
- 2.0.16 — 2025-10-01
- 2.0.15 — 2025-03-26
- 2.0.14 — 2025-02-18
- 2.0.13 — 2024-09-24
- 2.0.12 — 2024-06-06
- 2.0.11 — 2024-03-11
- 2.0.10 — 2023-10-22
- 2.0.9 — 2023-10-19
- 2.0.8 — 2023-10-17
- 2.0.7 — 2023-07-16
- 2.0.6 — 2023-03-31
- … 21 more at https://npm.io/package/nice-grpc-client-middleware-deadline/versions

## README

# nice-grpc-client-middleware-deadline [![npm version][npm-image]][npm-url]

Client middleware for [nice-grpc](https://github.com/deeplay-io/nice-grpc) that
adds support for setting deadline for a call, after which the call will get
cancelled, and a `ClientError` with status code `DEADLINE_EXCEEDED` will be
thrown.

## Installation

```
npm install nice-grpc-client-middleware-deadline
```

## Usage

```ts
import {
  createClientFactory,
  createChannel,
  ClientError,
  Status,
} from 'nice-grpc';
import {deadlineMiddleware} from 'nice-grpc-client-middleware-deadline';
import {addSeconds} from 'date-fns';

const clientFactory = createClientFactory().use(deadlineMiddleware);

const channel = createChannel(address);
const client = clientFactory.create(ExampleService, channel);

try {
  const response = await client.exampleMethod(request, {
    deadline: addSeconds(new Date(), 15),
  });
} catch (error: unknown) {
  if (error instanceof ClientError && error.code === Status.DEADLINE_EXCEEDED) {
    // timed out
  } else {
    throw error;
  }
}
```

Alternatively, you can specify deadline as a relative offset in milliseconds:

```ts
import ms from 'ms';

const response = await client.exampleMethod(request, {
  deadline: ms('15s'),
});
```

[npm-image]: https://badge.fury.io/js/nice-grpc-client-middleware-deadline.svg
[npm-url]: https://badge.fury.io/js/nice-grpc-client-middleware-deadline

---
_Source: https://npm.io/package/nice-grpc-client-middleware-deadline · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
