-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Describe the bug
See also vitejs/vite#13735.
This error can easily be triggered by hitting "r" key in vite CLI to restart the dev server.
Reproduction
Logs
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.0System Info
System:
OS: macOS 13.2
CPU: (10) arm64 Apple M2 Pro
Memory: 155.45 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.14.0 - ~/.nvm/versions/node/v18.14.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v18.14.0/bin/yarn
npm: 9.3.1 - ~/.nvm/versions/node/v18.14.0/bin/npm
pnpm: 8.6.3 - ~/.nvm/versions/node/v18.14.0/bin/pnpm
Browsers:
Chrome: 114.0.5735.198
Edge: 114.0.1823.41
Safari: 16.3
npmPackages:
@sveltejs/adapter-auto: ^2.0.0 => 2.1.0
@sveltejs/kit: ^1.20.4 => 1.22.1
svelte: ^4.0.0 => 4.0.5
vite: 4.4.2 => 4.4.2Severity
annoyance
Additional Information
It is introduced by this vite PR: vitejs/vite#13262.
The error 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.
ghostebony, hackape and Nuller-G