Introduction
After the installation, errors reach the dashboard in three ways: thrown out of a wrapped handler, escaping every handler as an unhandled error, or reported by you.Errors thrown by the handler
lerix.wrap(handler) catches what the handler throws, reports it, and answers
in its place:
Each report carries the request: method, URL without the query string,
route, status and a request id (
x-request-id, x-correlation-id, cf-ray
or x-vercel-id). Edge functions have no router to ask for a route, so
value-like path segments are replaced: /orders/8812/items is reported as
/orders/:id/items.
The error is still printed with console.error, so it keeps showing up in
your platform’s logs. Pass logErrors: false to stop that.
Customize the response
Choose what is reported
Unhandled errors
Errors that escape every handler, such as a rejected promise nobody awaited, are reported ascrash through the runtime’s error and
unhandledrejection events (Supabase/Deno, Cloudflare Workers, Vercel Edge).
Supabase ends the worker on such an error, normally before a report could be
sent. So the SDK holds the runtime’s default off until the report is out,
then rethrows the error and the worker ends as it would have. Pass
exitOnUnhandled: false to keep the worker serving instead.
On Supabase, queued reports are also sent on beforeunload, just before an
isolate shuts down. Set captureUnhandled: false to turn all of this off.
Report errors yourself
AsyncLocalStorage: Supabase, Deno, Bun and Cloudflare with
nodejs_compat provide it, and on Vercel Edge it is used when the runtime
exposes a global one. Errors thrown out of the handler carry the request
either way.
Both methods never throw. Outside wrap() (a cron-style function, a queue
consumer), hand the flush to the platform so the report is not lost when the
isolate stops:
Filter and edit reports
ignoreErrors and beforeSend work as in every other Lerix SDK:
RegExp
matches when it finds a match. beforeSend runs after ignoreErrors; return
null to drop the report. If it throws, the original report is sent.
When reports are sent
wrap() hands the sending to the first waitUntil it finds, so the response
is not delayed:
Limits
- Errors thrown while a streamed response body is being read happen after
wrap()has returned, so it does not see them. Catch them in the stream and callcaptureException. - Stack traces from Deno point at your TypeScript files directly. Bundled Workers and Vercel builds show bundle positions.