# @cspell/rpc

> Type Safe RPC library.

Latest version **10.3.3** (published 2026-09-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cspell/rpc
pnpm add @cspell/rpc
yarn add @cspell/rpc
bun add @cspell/rpc
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 10.3.3 |
| Published | 2026-09-16 |
| First published | 2026-02-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=22.18.0 |
| Dependencies | 0 |
| Unpacked size | 48.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1686 |
| Author | Jason Dent |
| Maintainers | jason-dent |
| Keywords | cspell, RPC, TypeScript |

## Links

- npm: https://www.npmjs.com/package/@cspell/rpc
- Repository: https://github.com/streetsidesoftware/cspell
- Homepage: https://github.com/streetsidesoftware/cspell/tree/main/packages/rpc#readme
- Issues: https://github.com/streetsidesoftware/cspell
- npm.io page: https://npm.io/package/@cspell/rpc

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 10.3.3 (latest) — 2026-09-16
- 10.3.4-alpha.0 (next) — 2026-09-17
- 10.3.2 — 2026-09-15
- 10.3.2-alpha.0 — 2026-09-13
- 10.3.1 — 2026-09-13
- 10.3.1-alpha.1 — 2026-09-12
- 10.3.1-alpha.0 — 2026-09-12
- 10.3.0 — 2026-09-08
- 10.3.0-alpha.0 — 2026-09-04
- 10.2.2 — 2026-09-04
- 10.2.1 — 2026-09-03
- 10.2.0 — 2026-08-31
- 10.2.0-alpha.7 — 2026-08-30
- 10.2.0-alpha.5 — 2026-08-30
- 10.2.0-alpha.4 — 2026-08-30
- … 11 more at https://npm.io/package/@cspell/rpc/versions

## README

# Simple RPC

A basic client / server RPC for sending the requests over a MessagePort.

This supports Node Worker Threads, Web Workers, or anything that can provide a MessagePortLike interface.

## Communication Details

The client and server communicate by sending messages over the MessagePort.

```ts
export interface RPCMessage {
  sig: 'RPC0';
  /**
   * A Unique identifier for the request/response.
   * Ideally this is a randomUUID.
   */
  id: RequestID;
  /**
   * The type of message being sent.
   */
  type: 'request' | 'response' | 'cancel' | 'canceled' | 'ok' | 'ready';
}

export type RPCRequestType = 'request' | 'cancel' | 'ok' | 'ready';

export type RPCResponseType = 'response' | 'canceled' | 'ok' | 'ready';
```

There are two types of messages: Request and Response. The client sends requests and the server sends responses.

### RPC Request

```mermaid
sequenceDiagram
    participant C as Client
    participant S as Server
    participant W as Worker
    C->>+S: Request <id>
    S->>+W: Method
    W->>-S: Result
    S->>-C: Response <id>, Result
```

### RPC Request with ACK

```mermaid
sequenceDiagram
    participant C as Client
    participant S as Server
    participant W as Worker
    C->>+S: Request <id>, ACK
    S->>C: ACK <id>
    S->>+W: Method
    W->>-S: Result
    S->>-C: Response <id>, Result
```

### RPC Request with Error

```mermaid
sequenceDiagram
    participant C as Client
    participant S as Server
    participant W as Worker
    C->>+S: Request <id>, ACK
    S->>C: ACK <id>
    S->>+W: Method
    W->>-S: Error
    S->>-C: Response <id>, Error
```

### OK Request

This request is used to check if the server is ok.

```mermaid
sequenceDiagram
    Client->>Server: OK <id>?
    Server->>Client: OK <id>, Code 200
```

### Cancel Request

A cancellation request is used to cancel or abort a request. The server accepts the request and acknowledges that it was received. Depending on the mode, the server either responds immediately without waiting for the worker to confirm the cancellation, or waits for that confirmation before responding:

#### Cancel Request: no wait

```mermaid
sequenceDiagram
    participant C as Client
    participant S as Server
    participant W as Worker
    C->>+S: Request <id>
    S->>+W: Method
    C->>S: Cancel <id>
    S->>-C: Canceled <id>
    S--xW: Cancel
    W--x-S: Canceled
```

#### Cancel Request: wait

```mermaid
sequenceDiagram
    participant C as Client
    participant S as Server
    participant W as Worker
    C->>+S: Request <id>
    S->>+W: Method
    C->>S: Cancel <id>, Wait
    S--xW: Cancel
    W-->>-S: Canceled
    S->>-C: Canceled <id>
```

### RPC Request, Canceled by Server

It can happen that the server needs to cancel requests. This can happen if the server is getting disposed and still has pending requests. It has a couple of ways to do this:

1. Send an Error Response
2. Send a Canceled Response

```mermaid
sequenceDiagram
    participant C as Client
    participant S as Server
    participant W as Worker
    C->>+S: Request <id>
    S->>+W: Method
    W--x-S: Canceled
    S->>-C: Canceled <id>
```

### Abort

An abort request is the same as a Cancel request, only the client will not wait on a response and the response will be ignored.

```mermaid
sequenceDiagram
    participant C as Client
    participant S as Server
    C->>S: Request <id>
    C-->>S: Cancel <id>
    S--xC: Canceled <id>
```

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