oven-sh/bun · error · TypeError

HTTP2ProtocolError

HTTP2ProtocolError

Error message

HTTP2ProtocolError

What it means

HTTP/2 error variant for the generic PROTOCOL_ERROR code: the connection hit a frame-level protocol violation that has no more specific code (unexpected frame type in the current state, bad flags, malformed header block). It surfaces from frame handling in src/http when the peer's byte stream deviates from the HTTP/2 spec.

Solutions

  1. Capture the failing frame type/connection state to identify which spec rule the peer violated
  2. Fix the client implementation sending the non-conforming frames, or terminate the connection with GOAWAY as the protocol prescribes
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/http/error.rs:16 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/5bc1ca1a8e062fe6. Report an issue: GitHub.

Appendix: source

Thrown at src/http/error.rs:16

#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
pub enum Error {
    #[error("CompressionFailed")]
    CompressionFailed,
    #[error("Aborted")]
    Aborted,
    #[error("WriteFailed")]
    WriteFailed,
    #[error("HTTP2RefusedStream")]
    HTTP2RefusedStream,
    #[error("HTTP2ContentLengthMismatch")]
    HTTP2ContentLengthMismatch,
    #[error("HTTP2FrameSizeError")]
    HTTP2FrameSizeError,
    #[error("HTTP2ProtocolError")]
    HTTP2ProtocolError,
    #[error("HTTP2FlowControlError")]
    HTTP2FlowControlError,
    #[error("HTTP2EnhanceYourCalm")]
    HTTP2EnhanceYourCalm,
    #[error("HTTP2HeaderListTooLarge")]
    HTTP2HeaderListTooLarge,
    #[error("HTTP2StreamReset")]
    HTTP2StreamReset,
    #[error("HTTP2GoAway")]
    HTTP2GoAway,
    #[error("HTTP2CompressionError")]
    HTTP2CompressionError,
    #[error("Timeout")]
    Timeout,
    #[error("AbortedBeforeConnecting")]
    AbortedBeforeConnecting,
    #[error("InvalidURL")]

View on GitHub (pinned to 8c5296ac45)