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(ssr): handle error from restart #13767

Closed
wants to merge 2 commits into from
Closed

fix(ssr): handle error from restart #13767

wants to merge 2 commits into from

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jul 10, 2023

Description

fix #13735

The bug comes from this SvelteKit code, which runs ssrLoadModule immediately on reload request.

Additional context

It's hard to make the test error reliably, so added a very simple one for now. I noticed it may happen once in a while which we could catch.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@stackblitz
Copy link

stackblitz bot commented Jul 10, 2023

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

@bluwy
Copy link
Member Author

bluwy commented Jul 10, 2023

So my test actually caused a fail, and I did saw that error happening locally once in a while. I try to check again that later tonight, or otherwise remove the test for now.

Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this @bluwy! I have doubts if this is the best long-term solution. I'm afraid there could be some global state that gets corrupted because this error wasn't handled. With the browser we know there will be a hard reload but that isn't the case with ssrLoadModule. Should SvelteKit have a try/catch and ignore the error instead?

I think your solution is good for a change done in a minor though. So we better merge it and then we could review in Vite 5 if we should rework this.

@patak-dev
Copy link
Member

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

vite-ecosystem-ci bot commented Jul 10, 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

@bluwy
Copy link
Member Author

bluwy commented Jul 10, 2023

Actually, yeah. I did this fix a bit too quick, it indeed seems like it would cause an incorrect state in SvelteKit side 🤔 Maybe we should fix it there instead.

I thought fixing this here first because the error we emit is sort-of internal and it's meant for us to catch and not corrupt the state/server. Which in the issue's case it exits the server. (EDIT: after further checking, the exist could be cause by the hack instead.)

@bluwy
Copy link
Member Author

bluwy commented Jul 11, 2023

Discussed with patak that this isn't the right fix as it returns an incorrect state.

@bluwy bluwy closed this Jul 11, 2023
@bluwy bluwy deleted the fix-env-restart-error branch July 11, 2023 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[4.4.1] After update from 4.3.9, server crashes when changing .env file
2 participants