laingsimon / courage_scores

Record the scores of courage league darts fixtures
http://thecourageleague.co.uk
Apache License 2.0
0 stars 0 forks source link

[annoyance] SPA development webserver starts twice when vite takes longer to start #770

Open laingsimon opened 9 months ago

laingsimon commented 9 months ago

Not sure if this is caused by the SPA app within dotnet or npm start. It is also possible, with a slow start, that the browser - Chrome - refreshes the page causing the backend to relaunch the server.

Either way the npm or spa dotnet app should prevent a double launch of the dev server

If possible, it would be useful for the spa app to launch npm start in a background window

https://github.com/laingsimon/courage_scores/blob/0713d27de5182c39298c12c37d678e4b4f379cbd/CourageScores/CourageScores.csproj#L11-L12

Nuget Package: Microsoft.AspNetCore.SpaProxy

image

image

laingsimon commented 9 months ago

This could be vitejs or the dotnet core spa app, difficult to tell. It doesn't happen all the time, so suspect it is related to a slower than normal launch after a fresh build or branch switch

laingsimon commented 8 months ago

A change to this line would allow the window to open in the background/minimised

https://github.com/dotnet/aspnetcore/blob/708f27145d0f0fbb2910e7645f9c545c36838c45/src/Middleware/Spa/SpaProxy/src/SpaProxyLaunchManager.cs#L196

laingsimon commented 8 months ago

There is some unnecessary duplication in the SPA proxy launch manager: image

IsSpaProxyRunning can call directly onto the ProbeSpaDevelopmentServerUrl (after creating a HttpClient). The methods are identical otherwise.

laingsimon commented 8 months ago

Suspected cause:


Note 1: At this point the first process is orphaned, as the reference to it _spaProcess is rewritten to the details of the second process


Suggested changes:

  1. If _spaProcess is set to an instance, either:
    1. Terminate it before starting a new proxy back-end
    2. Wait for the process to exit before starting a new proxy back-end
    3. Defer to the existing process, i.e. dont create a new process
    4. Control this behaviour via a configuration switch (to retain existing behaviour if anyone requires it)
  2. Add new config settings:
    1. SubsequentStartMethod: ReLaunch (default, start another process) | Restart (kill and start another process) | WaitForFirst (trust the first process will get there eventually)
    2. WindowStyle: Normal (allow the os to position the window) | Minimized (minimize the process if the os allows it)
    3. Use this configuration to allow the proxy back-end console window to be minimised (hidden) by default
laingsimon commented 6 months ago

See changes here: https://github.com/dotnet/aspnetcore/pull/55375

laingsimon commented 6 months ago

Suggestion rejected by aspnet core developers. Remaining options are to: