Skip to content

fix: avoid early error when server is closed in ssr#13787

Merged
patak-cat merged 2 commits intomainfrom
fix/avoid-early-error-when-server-is-closed-in-ssr
Jul 11, 2023
Merged

fix: avoid early error when server is closed in ssr#13787
patak-cat merged 2 commits intomainfrom
fix/avoid-early-error-when-server-is-closed-in-ssr

Conversation

@patak-cat
Copy link
Copy Markdown
Member

Fixes #13735
Fixes #13786
Closes #13767

Description

Throwing an error during SSR would force the users to handle it on every call to ssrLoadModule. What is safer long term is something we should discuss for Vite 5. At least for 4.4 (and I'm leaning towards this approach for 5 too), it is better to avoid the error during SSR. The only reason it was added was to speed up server restart. During SSR, the requests should be fast enough.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

patak-cat and others added 2 commits July 11, 2023 13:54
Co-authored-by: Bjorn Lu <34116392+bluwy@users.noreply.github.com>
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@patak-cat patak-cat requested a review from bluwy July 11, 2023 12:02
@patak-cat
Copy link
Copy Markdown
Member Author

/ecosystem-ci run

@vite-ecosystem-ci
Copy link
Copy Markdown

vite-ecosystem-ci bot commented Jul 11, 2023

📝 Ran ecosystem CI: Open

suite result
analogjs ✅ success
astro ✅ success
histoire ❌ failure
iles ❌ failure
ladle ✅ success
laravel ✅ success
marko ✅ success
nuxt ✅ success
nx ✅ success
previewjs ✅ success
qwik ✅ success
rakkas ✅ success
sveltekit ✅ success
unocss ✅ success
vite-plugin-pwa ✅ success
vite-plugin-ssr ✅ success
vite-plugin-react ✅ success
vite-plugin-react-pages ✅ success
vite-plugin-react-swc ✅ success
vite-plugin-svelte ✅ success
vite-plugin-vue ✅ success
vite-setup-catalogue ✅ success
vitepress ✅ success
vitest ✅ success

Copy link
Copy Markdown
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems easier than expected!

res.status(200).set({ 'Content-Type': 'text/html' }).end(html)
} catch (e) {
vite && vite.ssrFixStacktrace(e)
if (isTest) throw e
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My test could be flaky as I haven't figured out some case where there's actually unexpected but harmless errors. I'm ok with leaving this out in case it makes our CI unstable 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI looks good for now. If we see it starts to bring issues we can remove it later.

@patak-cat patak-cat merged commit 89d01eb into main Jul 11, 2023
@patak-cat patak-cat deleted the fix/avoid-early-error-when-server-is-closed-in-ssr branch July 11, 2023 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants