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(server): remove restart guard on restart #13789

Merged
merged 1 commit into from Jul 11, 2023
Merged

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jul 11, 2023

Description

fix #13735

On server restart, we assign the _restartPromise of the old server to the new server to prevent the new server's restart() from working (to prevent chaos like port collision, proper server listen/teardown). This was done in #7004 (the guard)

However, #13262 uses _restartPromise for another purpose -- throw on outdated request. That means there's a short interim during server listen that _restartPromise exist as a guard, but the server isn't actually outdated.

#13735 showed an edge case in SvelteKit where it calls ssrLoadModule in this interim causing it to falsely error.

This PR removes that guard as I don't think it's useful? On initial server startup we aren't guarding it either.

Additional context


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 11, 2023

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

@bluwy bluwy requested a review from patak-dev July 11, 2023 13:29
@patak-dev
Copy link
Member

/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

@patak-dev
Copy link
Member

Oh, I didn't see this one. I think it is ok to merge this PR to fix the edge case after #13262. We may still want a init guard that prevents restarts while the server is starting (so it also works on server starts), but that could be done in another PR if we think it is justified.

@patak-dev patak-dev merged commit 2a38ef7 into main Jul 11, 2023
13 checks passed
@patak-dev patak-dev deleted the remove-restart-guard branch July 11, 2023 14:12
@RIP21
Copy link

RIP21 commented Jul 18, 2023

BTW. This or something else may trigger a weird restart loop in watch mode.
One of my colleagues has issues that it goes into a cycle of restarts due to ".env" files change (they're not changing).

For me, it happens too, but stops after 3-5 retries.

@RIP21
Copy link

RIP21 commented Jul 18, 2023

Ok, it gets into that state for me too, but in different copy of the repo.

Very weird behaviour :/
CleanShot 2023-07-18 at 09 46 26@2x

@RIP21
Copy link

RIP21 commented Jul 18, 2023

Reverting Vite version all the way to 4.3.9 prevents it from happening. It just gets into it 2-3 times and then stops. Next time I run dev it's not getting into this state at all.
I also noticed that I'm getting some weird vite.config.js.timestamp.js or so file and it appears and disappears sometimes (maybe this is what causing it too?).

@bluwy
Copy link
Member Author

bluwy commented Jul 18, 2023

If it's happening in 4.3.9 too, it's likely not quite related to this PR. I'd suggest removing your Vite plugins one by one to figure out which is touching the env files or vite config files that causes the restart. Otherwise a quick workaround for now is to configure server.watch.ignored: ['**/vite.config.ts', '**/.env.*'] to skip Vite detecting their changes.

@RIP21
Copy link

RIP21 commented Jul 18, 2023

@bluwy probably. Maybe it's a Sentry plugin. I'll look into it later. But for now, somehow 4.3.9 still fixed it for everyone.

Thanks for the hint 🫡

@RIP21
Copy link

RIP21 commented Jul 19, 2023

Yeah, it's @sentry/vite-plugin to blame. Commenting it out solves the problem.
https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/vite-plugin

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
3 participants