Skip to content

Commit b6156f6

Browse files
committed
Update ServeCommand.php
1 parent 62610ce commit b6156f6

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

packages/framework/src/Console/Commands/ServeCommand.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -241,31 +241,17 @@ protected function isPortAvailable(int $port): bool
241241
}
242242

243243
/**
244-
* Clean up the vite.hot file with Windows-compatible handling.
244+
* Clean up the vite.hot file when the serve command terminates.
245245
*
246246
* This ensures that the hot file is properly removed when the serve command
247247
* terminates, preventing stale files from causing issues in subsequent runs.
248-
* On Windows, file cleanup may require multiple attempts due to file locking.
249248
*/
250249
protected function cleanupViteHotFile(): void
251250
{
252251
$hotFile = 'app/storage/framework/runtime/vite.hot';
253252

254253
if (Filesystem::exists($hotFile)) {
255-
// On Windows, file locking can prevent immediate deletion
256-
// so we use retry logic with small delays
257-
$maxAttempts = PHP_OS_FAMILY === 'Windows' ? 3 : 1;
258-
259-
for ($attempt = 1; $attempt <= $maxAttempts; $attempt++) {
260-
if (Filesystem::unlinkIfExists($hotFile)) {
261-
break; // Successfully deleted
262-
}
263-
264-
// If on Windows and not the last attempt, wait before retrying
265-
if (PHP_OS_FAMILY === 'Windows' && $attempt < $maxAttempts) {
266-
usleep(100000); // 100ms delay
267-
}
268-
}
254+
Filesystem::unlinkIfExists($hotFile);
269255
}
270256
}
271257
}

0 commit comments

Comments
 (0)