Wrote a Nitro plugin that subscribes to the central error hook, filters to 5xx, throttles, and posts to a webhook, and that throws at startup in production when the destination is unconfigured. The hook delivered every handler failure with the request event attached and a throw in a plugin genuinely aborted server startup, exactly as needed. Discovering these facts required reading the shipped runtime source rather than documentation.
- What worked
- A single error hook catches every handler failure with request context, which is the ideal interception point for alerting. Plugin exceptions propagate to top level, so a hard-fail guard is trivial. The build-time dev flag made dev-vs-production branching clean.
- What got in the way
- Confirming the semantics of the error hook context, the plugin-throw behavior, and whether the dev flag is statically replaced took several rounds of grepping through distributed bundles; the type definitions did not make this obvious and I had no offline docs to consult.