Fastify error tracking your coding agent can read
Updated 2026-11-05
Fastify sends every thrown error through one handler, which makes it a clean place to report. Runheed records server errors with the method, URL and route pattern (/orders/:id rather than each id), and leaves validation errors and other 4xx responses out. The SDK also catches uncaught exceptions and unhandled rejections on its own. Your agent reads the errors over MCP.
Set it up
1.Install the SDK.
terminalbashnpm install https://runheed.com/dl/runheed-0.1.0.tgz2.Initialize it before your app code and set the error handler before you register routes. Tested with Fastify 5.
server.tstypescriptimport Fastify from 'fastify'; import runheed from 'runheed'; runheed.init({ dsn: process.env.RUNHEED_DSN!, environment: process.env.NODE_ENV, release: process.env.GIT_SHA }); const app = Fastify(); app.setErrorHandler((err, request, reply) => { // Validation errors and other 4xx are responses you chose; report server errors only. if ((err.statusCode ?? 500) >= 500) { runheed.captureException(err, { method: request.method, url: request.url, route: request.routeOptions?.url }); } reply.send(err); }); // ...your routes await app.listen({ port: 3000 });3.Connect your agent with the server URL and a sign-in (Claude Code shown; Cursor, claude.ai and ChatGPT take the same URL).
terminalbashclaude mcp add --transport http runheed https://runheed.com/api/mcp
The npm and PyPI releases are not out yet, so these commands install the same package files straight from runheed.com. Nothing else changes when the registry versions ship.
What it catches
- Errors thrown in routes and hooks, with method, URL and route pattern
- Uncaught exceptions and unhandled promise rejections in the process
- Errors you report yourself with runheed.captureException(err, { anything: "useful" })
What it does not do
- A plugin that sets its own error handler handles errors in its scope, so add the same capture call there
- On a serverless host, await runheed.flush() after reporting: the Node SDK batches events for up to 5 seconds
- No performance tracing: Runheed tracks errors only
Then ask your agent
> what broke in production since the last deploy? fix the top one and resolve it with the commit hash
Connect Runheed first: Claude Code, Cursor or another client. Then see how the agent fixes and resolves an error.
Common Fastify errors
- Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
- ZodError: [ { "expected": "string", "code": "invalid_type", "path": [ "email" ], "messa...
- TypeError: Cannot destructure property 'id' of 'undefined' as it is undefined.
- [UnhandledPromiseRejection: This error originated either by throwing inside of an async...
- Error: EMFILE: too many open files, open '/app/uploads/0412.jpg'
- [ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
- PrismaClientInitializationError: Can't reach database server at `db.example.com:5432`
- TypeError: Client is not a constructor