Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/vite/src/client/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ kbd {
`

// Error Template
let template: HTMLElement
const createTemplate = () =>
h(
'div',
Expand Down Expand Up @@ -214,9 +213,7 @@ export class ErrorOverlay extends HTMLElement {
constructor(err: ErrorPayload['err'], links = true) {
super()
this.root = this.attachShadow({ mode: 'open' })

template ??= createTemplate()
this.root.appendChild(template)
this.root.appendChild(createTemplate())

codeframeRE.lastIndex = 0
const hasFrame = err.frame && codeframeRE.test(err.frame)
Expand Down
23 changes: 23 additions & 0 deletions playground/html/__tests__/html.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,29 @@ describe.runIf(isServe)('invalid', () => {
expect(isVisbleOverlay).toBeFalsy()
})

test('stack is updated', async () => {
await page.goto(viteTestUrl + '/invalid.html')

const errorOverlay = await page.waitForSelector('vite-error-overlay')
const hiddenPromise = errorOverlay.waitForElementState('hidden')
await page.keyboard.press('Escape')
await hiddenPromise

viteServer.hot.send({
type: 'error',
err: {
message: 'someError',
stack: [
'Error: someError',
' at someMethod (/some/file.ts:1:2)',
].join('\n'),
},
})
const newErrorOverlay = await page.waitForSelector('vite-error-overlay')
const stack = await newErrorOverlay.$$eval('.stack', (m) => m[0].innerHTML)
expect(stack).toMatch(/^Error: someError/)
})

test('should reload when fixed', async () => {
await page.goto(viteTestUrl + '/invalid.html')
await editFile('invalid.html', (content) => {
Expand Down