At any point before or during the , reply.hijack()
can be called to prevent Fastify from:
- Running all the following hooks and user handler
- Sending the response automatically
Reply Lifecycle
Whenever the user handles the request, the result may be:
- in async handler: it returns a payload
- in async handler: it throws an
Error
- in sync handler: it sends a payload
- in sync handler: it sends an
Error
instance
└─▶ schemaErrorFormatter
│
reply sent ◀── JSON ─┴─ Error instance
│
│ ★ throw an Error
★ send or return │ │
│ ▼ │
reply sent ◀── JSON ─┴─ Error instance ──▶ setErrorHandler ◀─────┘
│
reply sent ◀── JSON ─┴─ Error instance ──▶ onError Hook
│
└─▶ reply sent
Note: means that the JSON payload will be serialized by:
- the if set
- or by the default
JSON.stringify
function