Repository navigation
Description
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
pnpm installpnpm reprocallsbuild()andcreateServer()once per hook and printsmessage,pluginandhookfrom each error. OnlybuildStartduringbuild()has them.pnpm build:configshows 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.5Used 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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Activity
sapphi-red commentedon Nov 2, 2026
This sounds like a good addition to me.
materwelonDhruv commentedon Nov 2, 2026
Lets goo. You mind if I PR this? And what shape dyu think would be fine. the
[plugin name]like rolldown? orpluginandhookkeys on the error? or both?sapphi-red commentedon Nov 2, 2026
Feel free to make a PR 👍
pluginandhookkeys on the error and then use thisenhanceRollupErrorfunction to add them to the message.vite/packages/vite/src/node/build.ts
Line 954 in 90bc034
The general direction would be to change the errors happened in the plugin container to be similar to Rollup / Rolldown.
fix: add plugin name to hook errors (fix vitejs#23958)