Type alias UWSProxyErrorHandler

UWSProxyErrorHandler: ((error: Error, decodedRequest: UWSDecodedRequest) => UWSProxyErrorResponse | void | Promise<UWSProxyErrorResponse | void>)

Type declaration

    • (error: Error, decodedRequest: UWSDecodedRequest): UWSProxyErrorResponse | void | Promise<UWSProxyErrorResponse | void>
    • Called on request error. Can be used as a hook to change the Proxy error response if an UWSProxyErrorResponse is returned. Supports promises. This can return a promise or not.

      If no (or falsy) result is returned, the Proxy will respond with default error handling. This behavior allows for custom logging or whatever.

      You may want to take those NodeJS error codes into consideration:

      • ECONNRESET
      • ECONNABORT
      • ECONNREFUSED
      • ETIMEDOUT

      See NodeJS Error Codes for more information.

      The proxy may give you some custom codes:

      • E_RECIPIENT_ABORTED: the recipient server aborted either with partial or no response at all. It may or may not have received the request. In this scenario, the original error is passed to the Error constructor as cause, and the original error code (if any) can be found in error.original_error.
      • E_PIPELINE_ABORTED: the pipeline was aborted before the request was sent to the recipient server, or before the response was received from the recipient server.
      • E_PIPELINE_OVERFLOW: the pipeline aborted because the number of requests it received exceeded. increase maxPipelinedRequestsByConnection or maxConnectionsByHost to avoid this error
      • E_INVALID_CONTENT_LENGTH: The response parser received a Content-Length header with an invalid value.
      • E_INVALID_CHUNK_LENGTH: The response parser received a chunk length with an invalid value.

      Parameters

      Returns UWSProxyErrorResponse | void | Promise<UWSProxyErrorResponse | void>

Generated using TypeDoc