@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 +30 -6
- package/dist/chunk-3UODRQBD.js +878 -0
- package/dist/chunk-HBH64LWQ.cjs +878 -0
- package/dist/{chunk-VIP2EL47.js → chunk-KWAJIELR.js} +304 -201
- package/dist/{chunk-3P573RHA.cjs → chunk-S6WJ5YLP.cjs} +304 -201
- package/dist/{chunk-FV64SIRQ.cjs → chunk-STOXJZ7Z.cjs} +21 -10
- package/dist/{chunk-D3PJ7TQ4.js → chunk-V65UY6LU.js} +13 -2
- package/dist/cli.cjs +36 -9
- package/dist/cli.js +32 -5
- package/dist/index.cjs +622 -281
- package/dist/index.d.cts +152 -11
- package/dist/index.d.ts +152 -11
- package/dist/index.js +403 -62
- package/dist/testing.cjs +8 -8
- package/dist/testing.js +2 -2
- package/package.json +2 -1
- package/dist/chunk-FYMEBULO.js +0 -203
- package/dist/chunk-LYXQC4FI.cjs +0 -203
package/README.md
CHANGED
|
@@ -240,16 +240,34 @@ initAutterServer({ ..., instrumentations: [new ExpressInstrumentation()] });
|
|
|
240
240
|
|
|
241
241
|
### Server errors keep their stacks
|
|
242
242
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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
|
|
252
|
-
// Records the error, then calls
|
|
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
|