File tree 1 file changed +18
-4
lines changed
packages/vite/src/node/server/middlewares
1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -77,10 +77,24 @@ export function errorMiddleware(
77
77
<meta charset="UTF-8" />
78
78
<title>Error</title>
79
79
<script type="module">
80
- import { ErrorOverlay } from '/@vite/client'
81
- document.body.appendChild(new ErrorOverlay(${ JSON . stringify (
82
- prepareError ( err ) ,
83
- ) . replace ( / < / g, '\\u003c' ) } ))
80
+ const error = ${ JSON . stringify ( prepareError ( err ) ) . replace (
81
+ / < / g,
82
+ '\\u003c' ,
83
+ ) }
84
+ try {
85
+ const { ErrorOverlay } = await import('/@vite/client')
86
+ document.body.appendChild(new ErrorOverlay(error))
87
+ } catch {
88
+ const h = (tag, text) => {
89
+ const el = document.createElement(tag)
90
+ el.textContent = text
91
+ return el
92
+ }
93
+ document.body.appendChild(h('h1', 'Internal Server Error'))
94
+ document.body.appendChild(h('h2', error.message))
95
+ document.body.appendChild(h('pre', error.stack))
96
+ document.body.appendChild(h('p', '(Error overlay failed to load)'))
97
+ }
84
98
</script>
85
99
</head>
86
100
<body>
You can’t perform that action at this time.
0 commit comments