Skip to content

Commit

Permalink
fix(browser): wait until vite finishes prebundling of vitest dependen…
Browse files Browse the repository at this point in the history
…cies (#4518)
  • Loading branch information
sheremet-va committed Nov 16, 2023
1 parent 648bccb commit 56ee702
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/browser/src/client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,16 @@ async function reportUnexpectedError(rpc: typeof client.rpc, type: string, error
ws.addEventListener('open', async () => {
await loadConfig()

const { getSafeTimers } = await importId('vitest/utils') as typeof import('vitest/utils')
const safeRpc = createSafeRpc(client, getSafeTimers)
let safeRpc: typeof client.rpc
try {
// if importing /@id/ failed, we reload the page waiting until Vite prebundles it
const { getSafeTimers } = await importId('vitest/utils') as typeof import('vitest/utils')
safeRpc = createSafeRpc(client, getSafeTimers)
}
catch (err) {
location.reload()
return
}

stopErrorHandler()
stopRejectionHandler()
Expand Down

0 comments on commit 56ee702

Please sign in to comment.