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

JSError

Error message

JSError

What it means

Variant of the bundler Error enum wrapping a bun_core::JsError: a JavaScript-level error or exception occurred during bundling (e.g. a JS-side plugin callback threw, or execution of build-time JS failed). The variant name is the display message prefix; the inner JsError carries the actual JS error details.

Solutions

  1. Read the wrapped JS stack trace to find the throwing plugin/hook code
  2. Wrap user plugin callbacks in try/catch and return structured errors
  3. Fix or disable the misbehaving JS-side extension
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/bundler/error.rs:41 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/d984a8378a93afdf. Report an issue: GitHub.

Appendix: source

Thrown at src/bundler/error.rs:41

    #[error("InvalidJSON")]
    InvalidJSON,
    #[error("Fail")]
    Fail,
    #[error("ParserError")]
    ParserError,
    #[error("SyntaxError")]
    SyntaxError,
    #[error("MinifyError")]
    MinifyError,
    #[error("InvalidNativePlugin")]
    InvalidNativePlugin,
    #[error("EmptyAST")]
    EmptyAST,
    #[error("FormatError")]
    FormatError,
    #[error("ResolveMessage")]
    ResolveMessage,
    #[error("JSError")]
    Js(bun_core::JsError),
    #[error(transparent)]
    Sys(#[from] bun_errno::SystemErrno),
    #[error(transparent)]
    Alloc(#[from] bun_alloc::AllocError),
    #[error(transparent)]
    Core(#[from] bun_core::Error),
    #[error(transparent)]
    JsPrinter(#[from] bun_js_printer::Error),
    #[error(transparent)]
    Resolver(#[from] bun_resolver::Error),
    #[error(transparent)]
    Dotenv(#[from] bun_dotenv::Error),
    #[error(transparent)]
    JsParser(#[from] bun_js_parser::Error),
    #[error(transparent)]
    Parsers(#[from] bun_parsers::Error),
    #[error(transparent)]

View on GitHub (pinned to 8c5296ac45)