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
    1. └─▶ schemaErrorFormatter
    2. reply sent ◀── JSON ─┴─ Error instance
    3. throw an Error
    4. send or return
    5. reply sent ◀── JSON ─┴─ Error instance ──▶ setErrorHandler ◀─────┘
    6. reply sent ◀── JSON ─┴─ Error instance ──▶ onError Hook
    7. └─▶ reply sent

    Note: means that the JSON payload will be serialized by:

    • the if set
    • or by the default JSON.stringify function