Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Jul 11, 2023

Conversation

patak-dev
Copy link
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-dev and others added 2 commits July 11, 2023 13:54
Co-authored-by: Bjorn Lu <34116392+bluwy@users.noreply.github.com>
@stackblitz
Copy link

stackblitz bot commented Jul 11, 2023

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

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

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

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
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!

@@ -57,6 +57,7 @@ export async function createServer(
res.status(200).set({ 'Content-Type': 'text/html' }).end(html)
} catch (e) {
vite && vite.ssrFixStacktrace(e)
if (isTest) throw e
Copy link
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
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-dev patak-dev merged commit 89d01eb into main Jul 11, 2023
20 checks passed
@patak-dev patak-dev 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