Capture & report errors

Unexpected errors go through server hooks. Use the Node runtime to report handled errors.

Unexpected errors

Server handleError reports unexpected failures. error(), redirect(), and fail() are not reported. Server handleError attaches runtime recorder evidence when the recorder is on.

Capture exceptions

Call captureException on the server runtime for handled errors. Pass observation from scope.observeError(error) to attach recorder evidence.

try {
  await chargeCustomer();
} catch (error) {
  const observation = scope.observeError(error);
  server.captureException(error, { observation });
}

Send pending events before exit

adapter-node servers flush on shutdown. Call flush yourself before a script or other short-lived process exits.

await server.flush();

Server options

Pass these fields to node().

FieldRequiredWhat it does
dsnRequiredPublic project DSN from project settings. Used only to send events.
projectApiKeyRequiredSecret project API key for deploy announcement and source-inventory upload.
environmentRequiredWhere the error happened: local, staging, or production.
releaseRequiredThe Git commit SHA for this deployment. Use the same SHA on the Vite plugin.
enabledOptionalTurns reporting on or off. Defaults to true.
logSuccessOptionalPrints a configuration summary when setup succeeds. Defaults to false; set to true to enable.
installGlobalHandlersOptionalWatch process uncaughtException and unhandledRejection. Defaults to off; set to true to enable.
executionRecorderOptionalLimits and redaction for the runtime recorder (on after install).
moduleUrlOptionalHelps normalize local stack paths. Use import.meta.url.
sourceRootOptionalThe Git folder for a single-package service when automatic matching is ambiguous.
sourceRootsOptionalPackage-name to Git-folder mappings for an ambiguous monorepo.
apiUrlOptionalOverride the API origin from the DSN. Leave unset unless you self-host.