-
Notifications
You must be signed in to change notification settings - Fork 26
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
bringing in http1 changes #146
Conversation
Project.toml
Outdated
@@ -1,7 +1,7 @@ | |||
name = "LiveServer" | |||
uuid = "16fef848-5104-11e9-1b77-fb7a48bbb589" | |||
authors = ["Jonas Asprion <jonas.asprion@gmx.ch", "Thibaut Lienart <tlienart@me.com>"] | |||
version = "0.9.2" | |||
version = "0.10.0" |
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.
I think this could be 0.9, there is nothing breaking here, right?
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.
well now 0.9.2
is HTTP 0.8, 0.9 but this one is just HTTP 1; also we bumped up the minimum req on Julia 1.6, that's why I thought it'd make sense to make it a 0.10
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.
Okay, I think it only matters if you plan on doing more patch releases supporting HTTP 0.8 and 0.9. Perhaps make this 1.0 instead then? Then you have more flexibility for future changes like this since you have three numbers to play around with.
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.
I think 1.0.0 once we're happy this is solid would make sense yes 👍
For the error when @async begin
for msg in ws
# pass
end
end without the |
Nice thanks, Edit error came from a line that should have been removed in the tests @mortenpi @fredrikekre @rikhuijzer if you guys could test the code a bit with your usual work streams so that we can gain confidence in it, that would be much appreciated. I'll do that for a week on my side with Franklin and related repos then we can merge this. Thanks! (Note: @mortenpi, I'm investigating the issue you neatly pointed out in #135 and think I have a fix, will probably do that in a separate PR though as I want to have time to test stuff in details) |
For me, it doesn't crash anymore. On the other hand, when sending a few dozen changes to the server, it seems to now do one page reload per changed file whereas before it was more relaxed and dropped some reloads. Is it possible that this behavior has changed with the fix? More specifically, what happens here is that changing many files will cause the webpage to be refreshed once every second for the next 20 seconds even when no files are changed. EDIT: And the following error shows in the console. But only 5 times so it is probably unrelated to the many refreshes.
|
@rikhuijzer thanks! would you might trying again the refresh thing? it might have been a sleep that was unnecessarily long, it used to be shorter; Also for what you report with the error; you saw it with |
I switched to using this branch now, and so far so good! But if anything does pop up, I'll make sure to post here. |
I'm seeing something like this too, will try to figure out how to avoid this; also the refresh don't seem to work well with Safari for some reason. |
Yes. I'm also doing more tests here and I'm running into this too on Firefox. When I change a file then the page refreshes but without updating the content. This happens on every file change in some situations. Let me know if you need a MWE. It will probably take me 30-120 minutes to make one. EDIT: On the bright side, I've had zero crashes so that's good. |
Looks like we'll need @quinnj's help again here, adding a
if there's only one tab open, there should only be one update and one close message right? It might be that the sleep time really needs to be 1.0s in ea81c46 ... but I'm going blind here (these things don't happen with the non-http1 version so it's a recent change that causes this afaik) |
Sorry for my ignorance, but can someone help me understand the expected behavior? i.e. when I change a file, the browser should refresh and show the updated content; but what if I change multiple files at the same time; that should only trigger one refresh, but show the updated content of all the files? |
@tlienart, can you try changing the definition of function update_and_close_viewers!(wss::Vector{HTTP.WebSockets.WebSocket})
# collect and empty! wss as soon as possible in case other
# file changes also happen quickly and we have races called here
websockets = collect(wss)
empty!(wss)
foreach(websockets) do wsi
try
send(wsi, "update")
close(wsi)
catch e
if VERBOSE[]
@error "update_and_close_viewers! error" exception=(e, catch_backtrace())
end
end
end
return nothing
end I think the problem here is that the new WebSockets code follows the spec more closely with regards to The solution here is to eagerly empty the websocket array and then initiate the update/closing sequences so we don't run into double closes. |
@ others watching this thread, kindly test the latest commit (7e33358) as, for me, it works as 0.9.2 did. Rest is probably mostly relevant for @quinnj. Thanks for taking the time to look into this again @quinnj, I don't understand HTTP's code enough to try to point you in the right direction so this is not super easy. Multi close seems like it could have been a problem indeed (it was not just two, it was many refreshes over a number of seconds). One thing is that in LS we don't want to wait for clean events, we just want things to be quick and robust. And it seems that the In the last commit, I go directly via For reference since you were asking above what the expected behaviour is (let's say with a single browser/tab to keep things simple)
This is the basic order of operation. Notes:
Closing timeEdit next commit 3afd7df seems to fix this with the use of It can take a couple of seconds to close all remaining ws and the server. This means that between the time a user presses CTRL+C and the actual end, there is a noticeable lag. This should be reduced as much as possible as, otherwise, the user might be tempted to hit CTRL+C again which may then cause other problems (e.g. crash the proper termination of Franklin). Maybe this (and the previous) could be addressed if there was an acceptable way in HTTP to say try to do X quickly and don't wait to see if it was successful. Ultimately on the LS side, we're not going to handle any unsuccessful closures so we don't want to have to wait until we get something that tells us it's (un)successful. This seems to be fixed if we use |
Works great here. Zero error or warnings in the terminal, zero disconnects, and functionality is as before. Thanks both! |
Thanks a lot for testing @rikhuijzer ! Latest commit seems to fix the slow server closing bit (using I'll leave this open a few days more for people to test and then merge. |
0.9.2 + #145 , thanks @quinnj and @fredrikekre who did most of the work. I also added some logic to close #139
I won't merge this before we've had some time to play with it and make sure that we're out of #143 .
It seems to work fine from my checks though the tests lead to an error upon (apparently) calling
close(ws)
in the test blockServer/ws_tracker testing
(actually the test block passes but the error is shown)Any idea how to clean that up?