-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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): should close server after create new server #12379
Conversation
Run & review this pull request in StackBlitz Codeflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following error happens when saving the config without any changes.
[ENOENT: no such file or directory, stat '/home/vitejs/vite/playground/assets/node_modules/.vite/deps_temp_c5a19aad'] {
code: 'ENOENT',
errno: -2,
path: '/home/vitejs/vite/playground/assets/node_modules/.vite/deps_temp_c5a19aad',
syscall: 'stat'
}
I guess it's happening because:
- the
deps_temp
directory is created bycreateServer
(but since it already exists the creation is skipped) - the
deps_temp
directory gets deleted byawait server.close()
- optimizer fails because
deps_temp
directory doesn't exist
When starting the new server, with the old server still lingering, wouldn't there be a chance the port would conflict? Maybe we need a callback when the new server's |
|
Ah I see, then we could go with this flow then once the issue sapphi brought up is resolved. Thanks for the explanation. |
I found that |
@@ -1271,8 +1271,11 @@ export async function cleanupDepsCacheStaleDirs( | |||
for (const dirent of dirents) { | |||
if (dirent.isDirectory() && dirent.name.includes('_temp_')) { | |||
const tempDirPath = path.resolve(config.cacheDir, dirent.name) | |||
const { mtime } = await fsp.stat(tempDirPath) | |||
if (Date.now() - mtime.getTime() > MAX_TEMP_DIR_AGE_MS) { | |||
const stats = await fsp.stat(tempDirPath).catch((_) => null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tempDirPath
maybe removed when server.close()
, so add a catch
to make clean up process work properly, this will solve sapphi-red's issue.
Error throwed by If needed, maybe we can add more context info to this error and expose it in debug mode @patak-dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Let's merge it so it makes it in Vite 4.2, @sun0day already resolved the issue reported by @sapphi-red.
I don't think users need to be aware of these errors 👍🏼 |
Description
fix #12375
superseds close #11680
Additional context
After this PR, current server will not be closed if creating new server fails, so we could tell user that server restart failed explicitly.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).