File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
packages/vite/src/node/server/middlewares Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -77,10 +77,24 @@ export function errorMiddleware(
7777 <meta charset="UTF-8" />
7878 <title>Error</title>
7979 <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+ }
8498 </script>
8599 </head>
86100 <body>
You can’t perform that action at this time.
0 commit comments