Server SDK

Error monitoring for Node.js

Capture uncaught exceptions and unhandled rejections across your Node services — Express, Fastify, or plain HTTP — and see them grouped in errorgap within seconds.

Frameworks Express · Fastify · plain NodeRequires Node 20+Package @errorgap/nodeSource ↗Package ↗Agent guide ↗
Install

Install

Add the package with your usual package manager.

sh
npm install @errorgap/node
Configure

Configure

Create an errorgap.ts (or errorgap.js) and import it as early as possible in your entry point, so the SDK is watching before the rest of the app boots.

ts
import { Errorgap } from "@errorgap/node";

Errorgap.init({
  endpoint:    process.env.ERRORGAP_ENDPOINT!,
  projectSlug: process.env.ERRORGAP_PROJECT_SLUG!,
  apiKey:      process.env.ERRORGAP_API_KEY!,
});
Keep the key in an environment variable (or your framework's secret store) — never commit it to source control.

init hooks uncaughtException and unhandledRejection for you. Framework adapters ship as subpath exports — add them if you run a web server:

Express

ts
import { errorgapErrorHandler } from "@errorgap/node/express";

app.use(errorgapErrorHandler()); // register last

Fastify

ts
import { errorgapPlugin } from "@errorgap/node/fastify";

await app.register(errorgapPlugin);
Trigger a test error

Trigger a test error

Throw once, with the SDK already imported, to confirm the in-app integration works end to end.

ts
import "./errorgap";

throw new Error("Errorgap test error");
Verify

Verify the connection

Confirm your key and endpoint reach errorgap before wiring anything else — send one event straight to the ingestion API:

bash
curl -sS -X POST "$ERRORGAP_ENDPOINT/api/projects/$ERRORGAP_PROJECT_SLUG/notices" \
  -H "content-type: application/json" \
  -H "x-errorgap-project-key: $ERRORGAP_API_KEY" \
  -d '{"errors":[{"type":"ErrorgapInstallTest","message":"Errorgap install verification"}]}'

A 201 with a group_id means ingestion works (202 = received but sampled; 401 = wrong key). Then trigger the test error above through the SDK. Your onboarding screen's Verify step checks the stack off automatically once the first event lands — it polls every three seconds.

Next: the full ingestion API, or browse every SDK.