npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

connect-errors

v0.1.2

Published

Proto-first, isomorphic error handling for Connect RPC — define errors in .proto, generate type-safe TypeScript constructors

Readme

connect-errors

Test Lint npm License: MIT

Define errors in .proto, generate type-safe TypeScript constructors, catch bugs at compile time.

The ECMAScript/TypeScript counterpart of connect-go-errors. A proto-first, isomorphic error handling package for Connect RPC that works on both server-side (Node.js, Bun, Deno) and client-side (React, Vue, Svelte, browser). Define your errors alongside your service definitions, run buf generate, and get fully typed constructor functions with typed parameters — no magic strings, no typos, no runtime surprises.

// Define in your .proto file
option (connecterrors.v1.error) = {
  code: "ERROR_USER_NOT_FOUND"
  message: "User '{{id}}' not found"
  connect_code: CODE_NOT_FOUND
};
// Use the generated typed constructor (server-side)
throw newUserNotFound({ id: req.id }); // ← IDE autocomplete, compile-time checked
// Match errors on the client
if (isUserNotFound(err)) {
  showToast("User not found!");
}

Wrong field name? Won't compile. Missing field? IDE warns you. Wrong error code? Doesn't exist.

Quick Start

npm install connect-errors

For code generation:

npm install -D connect-errors

Step 1: Configure Buf

First, add the protobuf dependency to your buf.yaml:

# buf.yaml
version: v2
modules:
  - path: proto
deps:
  - buf.build/balcieren/connect-errors

Run buf dep update to download the schema.

Option A: Local Mode

Configure buf.gen.yaml to use your local binary (installed via npm install -D connect-errors):

# buf.gen.yaml
version: v2

managed:
  enabled: true

plugins:
  - local: protoc-gen-es
    out: gen/ts
    opt: target=ts
  - local: protoc-gen-connect-es
    out: gen/ts
    opt: target=ts
  # ⭐ Local plugin binary provided by npm
  - local: protoc-gen-connect-errors-es
    out: gen/ts
    opt: target=ts

  # Note: If buf cannot find the plugin in your environment,
  # you can explicitly invoke it via npx:
  # - local: ["npx", "connect-errors"]
  #   out: gen/ts
  #   opt: target=ts

Then run buf via npx so it finds the binary in your node_modules:

npx buf generate

Option B: Basic Protoc (without Buf)

If you don't use Buf and rely on the standard protoc compiler, you can invoke the local plugin via npx directly in your terminal command:

npx protoc \
  --es_out=gen/ts \
  --connect-es_out=gen/ts \
  --connect-errors-es_out=gen/ts \
  --plugin=protoc-gen-connect-errors-es=./node_modules/.bin/protoc-gen-connect-errors-es \
  proto/service.proto

Step 2: Define Errors in Proto

See the full instructions for defining errors using the custom connecterrors.v1 proto options.

Step 3: Available Connect Error Codes

When defining errors in your .proto file, use the following values for the connect_code field. These map to standard Connect RPC status codes.

| connect_code | Description | | :------------------------- | :-------------------------------------------------------------------------------------- | | CODE_CANCELED | The operation was canceled. | | CODE_UNKNOWN | Unknown error. | | CODE_INVALID_ARGUMENT | Client specified an invalid argument. | | CODE_DEADLINE_EXCEEDED | Deadline expired before operation could complete. | | CODE_NOT_FOUND | Some requested entity was not found. | | CODE_ALREADY_EXISTS | Some entity that we attempted to create already exists. | | CODE_PERMISSION_DENIED | The caller does not have permission to execute the operation. | | CODE_RESOURCE_EXHAUSTED | Some resource has been exhausted (e.g. per-user quota). | | CODE_FAILED_PRECONDITION | Operation was rejected because the system is not in a state required for its execution. | | CODE_ABORTED | The operation was aborted. | | CODE_OUT_OF_RANGE | Operation was attempted past the valid range. | | CODE_UNIMPLEMENTED | Operation is not implemented or not supported/enabled. | | CODE_INTERNAL | Internal errors. | | CODE_UNAVAILABLE | The service is currently unavailable. | | CODE_DATA_LOSS | Unrecoverable data loss or corruption. | | CODE_UNAUTHENTICATED | The request does not have valid authentication credentials. |

Compatibility

| Environment | Supported | | ------------------ | --------- | | Node.js 18+ | ✅ | | Bun | ✅ | | Deno | ✅ | | Browser (ESM) | ✅ | | React / Next.js | ✅ | | Vue / Nuxt | ✅ | | Svelte / SvelteKit | ✅ | | React Native | ✅ |

Contributing

See CONTRIBUTING.md for guidelines.

License

MIT