@dispatchitapp/node
v1.0.0
Published
Node.js server SDK for Dispatch: global error handlers, V8 stack frames with source context, on top of @dispatchitapp/core.
Maintainers
Readme
@dispatchitapp/node
The Node.js server SDK for Dispatch. Builds on
@dispatchitapp/core, adding the two things a server needs that the core can't do
portably:
- V8 stack frames with source context — in-app frames carry the lines around the failing
line (
pre_context/context_line/post_context), read from disk, exactly like the gem. - Global error handlers —
processuncaughtException/unhandledRejection, the runtime-level analogue of the gem's Rack middleware +Rails.errorsubscriber.
import { init, captureException, report } from "@dispatchitapp/node";
init({
apiKey: process.env.DISPATCH_API_KEY!,
environment: process.env.NODE_ENV,
release: process.env.GIT_SHA,
// installGlobalHandlers: true (default) — capture uncaught errors + rejections
});
try {
doRiskyThing();
} catch (err) {
captureException(err, { tags: { area: "import" } });
}Framework middleware (Express, Fastify) lands in @dispatchitapp/express / @dispatchitapp/fastify and
builds on this package. Everything from @dispatchitapp/core is re-exported here, so a Node app
imports solely from @dispatchitapp/node.
Notes
initsetsplatform: "node", thedispatch-nodeSDK identity, and a source-context stack parser rooted atcwd(defaultprocess.cwd()).in_app= under the project root and not innode_modules/node:internals.- The handlers preserve Node's native crash behavior — capture, then print the error and
exit(1)(registering a listener would otherwise suppress both).uncaughtException: override withonFatalErrororexitOnUncaught: false.unhandledRejection: fatal by default exactly like Node's own--unhandled-rejections=throw; opt out withexitOnUnhandledRejection: false(this keeps the process alive, which Node alone would not). - Shutdown flush: the event queue drains on
beforeExitand before any fatal exit, budgeted byshutdownTimeout(ms, default 3000; the gem'sshutdown_timeoutanalogue). Disable thebeforeExithook withflushOnBeforeExit: false. Fatal events are taggedsource: uncaughtException/unhandledRejection(the gem'sat_exit/rakeanalogues).
Scripts
pnpm test · pnpm typecheck · pnpm build