Skip to content

Commit

Permalink
chore: optimize catch error login in vue3
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyuang committed Sep 21, 2024
1 parent 450d4ed commit 12dcd8a
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions packages/plugin-vue3/src/entry/server-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ const serverRender = async (ctx: ISSRContext, config: IConfig) => {
}

const state = Object.assign({}, store.state ?? {}, asyncData.value)
let err: any = null
const app = getApp({
state,
asyncData,
Expand All @@ -161,9 +160,8 @@ const serverRender = async (ctx: ISSRContext, config: IConfig) => {
inlineJsOrder,
rootId
})
if (!app.config.errorHandler) {
app.config.errorHandler = e => { err = e }
}

app.config.errorHandler = app.config.errorHandler ?? (e => { throw e })
app.use(router)
app.use(store)
app.use(pinia)
Expand All @@ -172,19 +170,12 @@ const serverRender = async (ctx: ISSRContext, config: IConfig) => {
app
}, async () => {
if (stream) {
const stream = renderToNodeStream(app)
if (err) {
throw err
}
return stream
return renderToNodeStream(app)
} else {
const teleportsContext: {
teleports?: Record<string, string>
} = {}
const html = await renderToString(app, teleportsContext)
if (err) {
throw err
}
return ({
html,
teleportsContext
Expand Down

0 comments on commit 12dcd8a

Please sign in to comment.