oven-sh/bun · error · http::Error

UnexpectedData

UnexpectedData

Error message

UnexpectedData

What it means

The HTTP parser received unexpected or malformed data that does not conform to the expected protocol framing. A catch-all sentinel for protocol-level data that arrives at an invalid point or in an invalid format.

Solutions

  1. Capture the raw bytes being parsed to identify the protocol violation
  2. Check for proxy or middleware corrupting the data stream
  3. Verify client and server are using the same HTTP version and framing rules
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/http/error.rs:56 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/ba401b701288b43f. Report an issue: GitHub.

Appendix: source

Thrown at src/http/error.rs:56

    #[error("ClientAborted")]
    ClientAborted,
    #[error("HTTP2Unsupported")]
    HTTP2Unsupported,
    #[error("ConnectionClosed")]
    ConnectionClosed,
    #[error("DNSResolveFailed")]
    DNSResolveFailed,
    #[error("ConnectionRefused")]
    ConnectionRefused,
    #[error("TooManyRedirects")]
    TooManyRedirects,
    #[error("HTTP3Unsupported")]
    HTTP3Unsupported,
    #[error("ResponseHeadersTooLarge")]
    ResponseHeadersTooLarge,
    #[error("UnrequestedUpgrade")]
    UnrequestedUpgrade,
    #[error("UnexpectedData")]
    UnexpectedData,
    #[error("InvalidHTTPResponse")]
    InvalidHTTPResponse,
    #[error("InvalidContentLength")]
    InvalidContentLength,
    #[error("UnsupportedTransferEncoding")]
    UnsupportedTransferEncoding,
    #[error("RequestBodyNotReusable")]
    RequestBodyNotReusable,
    #[error("UnsupportedRedirectProtocol")]
    UnsupportedRedirectProtocol,
    #[error("RedirectURLTooLong")]
    RedirectURLTooLong,
    #[error("RedirectURLInvalid")]
    RedirectURLInvalid,
    #[error("InvalidRedirectURL")]
    InvalidRedirectURL,
    #[error("UnexpectedRedirect")]

View on GitHub (pinned to 8c5296ac45)