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

[4.4.1] After update from 4.3.9, server crashes when changing .env file #13735

Closed
7 tasks done
SiNONiMiTY opened this issue Jul 6, 2023 · 6 comments · Fixed by #13787 or #13789
Closed
7 tasks done

[4.4.1] After update from 4.3.9, server crashes when changing .env file #13735

SiNONiMiTY opened this issue Jul 6, 2023 · 6 comments · Fixed by #13787 or #13789
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release

Comments

@SiNONiMiTY
Copy link

SiNONiMiTY commented Jul 6, 2023

Describe the bug

Previously on 4.3.9, when I change .env file, server restarts successfully

After upgrading to the latest version, server crashes when .env is changed

BEFORE

image

AFTER

  VITE v4.4.1  ready in 1272 ms

  ➜  Local:   http://localhost:5173/     
  ➜  Network: http://169.254.35.252:5173/
  ➜  Network: http://192.168.10.165:5173/
  ➜  Network: http://172.31.96.1:5173/   
  ➜  press h to show help
1:09:14 AM [vite] .env changed, restarting server...

const err = new Error('The server is being restarted or closed. Request is outdated');
                ^

Error: The server is being restarted or closed. Request is outdated
    at throwClosedServerError (node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-439026c8.js:43694:17)
    at loadAndTransform (node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-439026c8.js:54807:9)
    at async instantiateModule (node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-439026c8.js:55738:10) {
  code: 'ERR_CLOSED_SERVER'
}

Node.js v18.16.0

Reproduction

StackBlitz

Steps to reproduce

Change .env file while vite server is running

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 AMD Ryzen 5 3600XT 6-Core Processor
    Memory: 21.19 GB / 31.91 GB
  Binaries:
    Node: 18.16.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.6.1 - ~\AppData\Local\pnpm\pnpm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (114.0.1823.67)    
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    vite: ^4.4.1 => 4.4.1

Used Package Manager

pnpm

Logs

No response

Validations

@github-actions
Copy link

github-actions bot commented Jul 6, 2023

Hello @SiNONiMiTY. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@stackblitz
Copy link

stackblitz bot commented Jul 6, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@zonemeen
Copy link

zonemeen commented Jul 7, 2023

The issue seems to be caused by @sveltejs/kit/vite.

@hackape
Copy link

hackape commented Jul 8, 2023

This error can easily be triggered by hitting "r" key in CLI to restart the server.
@zonemeen Do you have more info to share? I'm using sveltekit and also encounter this issue wite vite v4.4.0+.

@hackape
Copy link

hackape commented Jul 8, 2023

Call stack shows this originates from align_exports function call in "@sveltejs/kit/vite", where it calls await vite.ssrLoadModule(...);. This happens in sveltekit plugin's "configureServer" hook, which is tapped when vite restartServer.

And since server._restartPromise = restartServer(server), but vite.ssrLoadModule will eventually call loadAndTransform containing this line: if (server._restartPromise) throwClosedServerError(), this error is always thrown.

This is introduced in #13262.

@RBird111
Copy link

RBird111 commented Jul 8, 2023

@hackape
Thanks for the background info! Going through it seems like there's already a guard on the server.restart() method so the new ones are redundant?
At any rate it looks like downgrading to Vite version 4.3.9 fixes the issue.
Screenshot 2023-07-08 094339
Screenshot 2023-07-08 094231

@bluwy bluwy added p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release and removed pending triage labels Jul 10, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jul 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release
Projects
None yet
6 participants