RickStrahl / Westwind.AspnetCore.LiveReload

ASP.NET Core Live Reload Middleware that monitors file changes in your project and automatically reloads the browser's active page
Other
469 stars 42 forks source link

Make sure we refresh only when the server is available #19

Closed RemiBou closed 4 years ago

RemiBou commented 4 years ago

Hi,

While testing this project I saw that most of the time the refresh occurs when the server is not available . This gives a connection closed error on the browser (chrome is nice and tries to detect when the server is available, but sometimes it fails).

This change detect when the server connection is really available and refresh only when it's ok. I think this makes the ServerRefreshTimeout useless as it'll refresh when the build is over (we can change it with a const value like 500).

I know this is an uncalled PR, sorry if it doesn't provide any value.

RemiBou commented 4 years ago

I added a Wait() on call to async operation during file watching because WebSocekt message were not sent.

RemiBou commented 4 years ago

I fixed the reconnection logic as multiple setInterval would be called despite the clearInterval call , now it seems to work fine : it connects to the websocket and reload the page when the connection is lost and suffesfully reconnected. cc @RickStrahl what do you think ?

RickStrahl commented 4 years ago

This looks good. I'll take a look hopefully later today. Thanks!

RickStrahl commented 4 years ago

Thanks Remi. I fixed up your change for the async .Wait() call because we don't need to wait for the result.

Thank you.

RemiBou commented 4 years ago

Thanks for the merge and thanks for your work :) I'll update my blog post with the nuget package (https://remibou.github.io/Make-your-Blazor-development-faster/)