← All platforms

Koa error tracking

An exception can travel through several layers of Koa middleware. The Sentry integration keeps its backtrace and sends the report to your Telebugs server.

~/hoofnotes  npm install @sentry/node
~/hoofnotes  nvim instrument.mjs app.mjs
import * as Sentry from "@sentry/node";
Sentry.init({
// Copy the complete Telebugs DSN, key and path included.
dsn: "YOUR_TELEBUGS_DSN",
});
import Koa from "koa";
import * as Sentry from "@sentry/node";
import { routes } from "./hoofnotes/routes.mjs";
const app = new Koa();
Sentry.setupKoaErrorHandler(app);
app.use(routes);
app.listen(3000);
~/hoofnotes  node --import ./instrument.mjs app.mjs

Space pauses or resumes. R replays. Escape shows the complete setup.

Hang on, I already use Sentry

Keep @sentry/node and change its destination to your Telebugs DSN. Your error reports stay on your server. You don’t need a Sentry account.

What about async middleware?

That is part of Koa’s error flow. The Sentry handler reports errors emitted by the application. If your middleware swallows an exception, you can report it explicitly too.

And the browser side?

Use the browser SDK for frontend errors. Your server and browser reports can live in Telebugs together without sharing the same SDK setup.