@autter/runtime-node 1.9.1 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -240,16 +240,34 @@ initAutterServer({ ..., instrumentations: [new ExpressInstrumentation()] });
240
240
 
241
241
  ### Server errors keep their stacks
242
242
 
243
- When a handler throws, the framework answers 500 — and on its own that 500
244
- is all the tracker sees: a stackless `HttpServerError` grouped by route. Add
245
- your framework's hook and the thrown error is recorded, with its stack, on
246
- the request span; the framework then carries on exactly as before.
243
+ **Express (4 and 5): automatic.** With `initAutterServer` alone, the error
244
+ behind a 5xx response is recorded on the request span with its type,
245
+ message and stack, plus the route and (with `autterRequests`) the request id.
246
+ That covers a handler that throws, an async handler that rejects (Express 5),
247
+ `next(err)`, and routers that have their own error handler. (Express 4
248
+ ignores the promise an async handler returns, so its rejection is an
249
+ unhandled rejection: recorded with the request's route and id, see below.)
250
+ Express's own
251
+ behaviour is unchanged. An error that ends in a 4xx response is not
252
+ reported this way, and neither is an error that `autterErrorHandler()` or
253
+ `captureException` already reported, so adding the handler never reports an
254
+ error twice. `captureExpressErrors: false` turns the automatic capture off.
255
+
256
+ **Everything else needs its hook.** When a Fastify or Koa handler throws, the
257
+ framework answers 500, and on its own that 500 is all the tracker sees: a
258
+ stackless `HttpServerError` grouped by route. Add your framework's hook and
259
+ the thrown error is recorded, with its stack, on the request span; the
260
+ framework then carries on exactly as before. On Express,
261
+ `autterErrorHandler()` still has two uses: it also reports coded errors that
262
+ end in a 4xx (and every error with `{ capture: true }`), and it works in
263
+ logger-only setups (`initAutterLogging`).
247
264
 
248
265
  ```ts
249
266
  import { autterErrorHandler, autterFastifyErrors, autterKoa, captureRequestError } from "@autter/runtime-node";
250
267
 
251
- // Express / Connect: after your routes, before your own error handlers.
252
- // Records the error, then calls next(err) unchanged.
268
+ // Express / Connect (optional on Express with initAutterServer): after your
269
+ // routes, before your own error handlers. Records the error, then calls
270
+ // next(err) unchanged. Once at app level covers nested routers too.
253
271
  app.use(autterErrorHandler());
254
272
 
255
273
  // Fastify 4/5: an onError hook (Fastify's error handler still answers).
@@ -365,6 +383,12 @@ receive origin `"uncaughtException"` rather than `"unhandledRejection"`.
365
383
  the 1.5.0 behaviour, where a rejection is seen only when it crashes the
366
384
  process.
367
385
 
386
+ A rejection from a promise started during a request, such as a floating
387
+ `void sendReceipt()` that fails after the response, keeps that request's
388
+ route, method and request id (`http.route`, `http.request.method`,
389
+ `autter.request.id` on its error span). The same holds for a crash, and for
390
+ a `captureException` call made after the response.
391
+
368
392
  ### Version compatibility: checked for you
369
393
 
370
394
  Some features need a minimum ingester version: operation logging needs