Describe the bug
I noticed that the middleware has a bug that it always waits for 5 seconds for the first request, even though the Vite dev server is already ready.
To Reproduce
Steps to reproduce the behavior:
Start the dev server manually in a separate terminal and keep it running
Start the asp.net core app
Fire a request and look at logs
Expected behavior
The request should be handled immediately because the dev server is already running.
Actual behavior
The log says this:
info: Vite.AspNetCore.Services.ViteServerLaunchManager[0]
Looks like the Vite development server is already running at http://localhost:44436.
warn: Vite.AspNetCore.Services.ViteDevMiddleware[0]
The Vite development server did not start within 5 seconds
And the request is delayed for 5 seconds until the warning log is shown.
Looking at the implementation, it tries to check if _waitForDevServer becomes false. However, there is no code changing the value (until timeout), so the first request is always delayed for the full timeout.
Describe the bug I noticed that the middleware has a bug that it always waits for 5 seconds for the first request, even though the Vite dev server is already ready.
To Reproduce Steps to reproduce the behavior:
Expected behavior The request should be handled immediately because the dev server is already running.
Actual behavior The log says this:
And the request is delayed for 5 seconds until the warning log is shown.
Additional context The implementation is here: https://github.com/Eptagone/Vite.AspNetCore/blob/main/src/Vite.AspNetCore/Services/ViteDevMiddleware.cs#L100
Looking at the implementation, it tries to check if
_waitForDevServer
becomes false. However, there is no code changing the value (until timeout), so the first request is always delayed for the full timeout.