Skip to content

Error middleware cannot display errors from plugin middlewares #17418

@benmccann

Description

@benmccann

Describe the bug

The error middleware requires JS to display anything:

import { ErrorOverlay } from '/@vite/client'

But sometimes you have an error that prevents the JS from loading:

Screenshot from 2024-06-07 15-08-58

In these cases you just get a blank page

Reproduction

n/a

Steps to reproduce

The error handler does not work with regular middlewares:

vite.middlewares.use((req, res, next) => {
	throw new Error('hello world');
});

It only works with post middlewares:

return () => {
	vite.middlewares.use((req, res) => {
		throw new Error('hello world');
	});
};

https://vitejs.dev/guide/api-plugin#configureserver

System Info

vite 5.2.8

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions