Commit 08907972 authored by JJ Kasper's avatar JJ Kasper Committed by Tim Neutkens

Only handle on catch in render (#6908)

To prevent slowing down we only handle on catch
parent bb4ecfb6
...@@ -334,6 +334,14 @@ export async function renderToHTML( ...@@ -334,6 +334,14 @@ export async function renderToHTML(
</RouterContext.Provider> </RouterContext.Provider>
const element = <Application/> const element = <Application/>
try {
return render(
renderElementToString,
element,
)
} catch (err) {
if (err && typeof err === 'object' && typeof err.then === 'function') {
await ssrPrepass(element) await ssrPrepass(element)
if (renderOpts.dataOnly) { if (renderOpts.dataOnly) {
return { return {
...@@ -341,13 +349,16 @@ export async function renderToHTML( ...@@ -341,13 +349,16 @@ export async function renderToHTML(
head: [], head: [],
dataOnly: true, dataOnly: true,
} }
} } else {
return render(
return await render(
renderElementToString, renderElementToString,
element, element,
) )
} }
}
throw err
}
}
} else { } else {
renderPage = ( renderPage = (
options: ComponentsEnhancer = {}, options: ComponentsEnhancer = {},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment