Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Aug 21, 2024
1 parent d4967d9 commit faab18e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/vike-node/src/plugin/plugins/devServerPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export function devServerPlugin(): Plugin {
globalStore.viteDevServer = vite
globalStore.setupHMRProxy = setupHMRProxy
patchViteServer(vite)
setupErrorHandler(vite)
setupErrorStrackRewrite(vite)
setupErrorHandlers()
initializeServerEntry(vite)
}
}
Expand Down Expand Up @@ -119,7 +120,7 @@ function logRestartMessage() {
logViteInfo('Server crash: Update a server file or type "r+enter" to restart the server.')
}

function setupErrorHandler(vite: ViteDevServer) {
function setupErrorStrackRewrite(vite: ViteDevServer) {
const rewroteStacktraces = new WeakSet()

const _prepareStackTrace = Error.prepareStackTrace
Expand All @@ -138,9 +139,11 @@ function setupErrorHandler(vite: ViteDevServer) {
const _ssrFixStacktrace = vite.ssrFixStacktrace
vite.ssrFixStacktrace = function ssrFixStacktrace(e) {
if (rewroteStacktraces.has(e)) return
return _ssrFixStacktrace(e)
_ssrFixStacktrace(e)
}
}

function setupErrorHandlers() {
function onError(err: unknown) {
console.error(err)
logRestartMessage()
Expand Down

0 comments on commit faab18e

Please sign in to comment.