Skip to content

Errors thrown in config, configResolved, configureServer or a dev server's buildStart don't say which plugin threw #23958

Description

@materwelonDhruv

Describe the bug

My CLI runs Vite through the JS API and prints error.message when something fails (stacks only show with --verbose). When a user's plugin throws in its config hook, all they get is the plugin's own message, like missing required option `apiKey` , with nothing saying which plugin it came from. The stack doesn't help either. The top frame is just BasicMinimalPluginContext.config in the bundled config file.

The same throw from buildStart during a build shows [plugin throws-in-buildStart], since Rolldown sets plugin and hook on the error. config, configResolved, configureServer and a dev server's buildStart don't. Looks like Vite only keeps the hook functions when it calls those, so the plugin's name is gone by the time one throws.

I'd expect these to say which plugin threw like Rolldown's do, either as [plugin name] in the message or as plugin and hook on the error (preferred). For now my CLI wraps every user plugin's hooks and rethrows with the name.

I'd like to PR this 🙏🏻

Reproduction

https://github.com/materwelonDhruv/repros/tree/main/vite/plugin-name-in-errors

Steps to reproduce

  1. pnpm install
  2. pnpm repro calls build() and createServer() once per hook and prints message, plugin and hook from each error. Only buildStart during build() has them.
  3. pnpm build:config shows the same thing from the CLI.

System Info

  System:
    OS: macOS 27.2
    CPU: (12) arm64 Apple M2 Max
    Memory: 178.78 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 26.13.0 - /Users/dhruv/.local/share/vite-plus/js_runtime/node/26.13.0/bin/node
    Yarn: 4.18.1 - /Users/dhruv/.local/share/vite-plus/fallback-bin/yarn
    npm: 11.20.0 - /Users/dhruv/.local/share/vite-plus/js_runtime/node/26.13.0/bin/npm
    pnpm: 12.14.0 - /Users/dhruv/Library/pnpm/bin/pnpm
    bun: 1.4.2 - /opt/homebrew/bin/bun
    Deno: 2.9.6 - /opt/homebrew/bin/deno
  Browsers:
    Brave Browser: 151.1.93.137
    Chrome: 156.0.8078.76
    Firefox: 157.0.1
    Safari: 27.2
  npmPackages:
    vite: 8.3.5 => 8.3.5

Used Package Manager

pnpm

Logs

Click to expand!

pnpm repro:

build()
  config: {"message":"missing required option `apiKey`"}
  configResolved: {"message":"missing required option `apiKey`"}
  buildStart: {"message":"Build failed with 1 error:\n\n[plugin throws-in-buildStart]\nError: missing required option `apiKey`"}
createServer()
  config: {"message":"missing required option `apiKey`"}
  configResolved: {"message":"missing required option `apiKey`"}
  configureServer: {"message":"missing required option `apiKey`"}
  buildStart: {"message":"missing required option `apiKey`"}

pnpm build:config:

error during build:
Error: missing required option `apiKey`
    at BasicMinimalPluginContext.config (file:///…/node_modules/.vite-temp/vite.config.ts.timestamp-1793417353608-cc51fb4e79c16.mjs:7:10)
    at runConfigHook (file:///…/node_modules/.pnpm/vite@8.3.5/node_modules/vite/dist/node/chunks/node.js:38288:42)
    at async resolveConfig (file:///…/node_modules/.pnpm/vite@8.3.5/node_modules/vite/dist/node/chunks/node.js:37695:11)

Validations

Activity

  1. added
    p2-nice-to-have
    on Nov 2, 2026
  2. sapphi-red commented on Nov 2, 2026

    @sapphi-red
    Member

    This sounds like a good addition to me.

  3. materwelonDhruv commented on Nov 2, 2026

    @materwelonDhruv
    ContributorAuthor

    Lets goo. You mind if I PR this? And what shape dyu think would be fine. the [plugin name] like rolldown? or plugin and hookkeys on the error? or both?

  4. sapphi-red commented on Nov 2, 2026

    @sapphi-red
    Member

    Feel free to make a PR 👍

    plugin and hook keys on the error and then use this enhanceRollupError function to add them to the message.

    export function enhanceRollupError(e: RollupError): void {

    The general direction would be to change the errors happened in the plugin container to be similar to Rollup / Rolldown.

  5. added a commit that references this issue on Nov 16, 2026
    87e2ad5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-nice-to-have

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions