Repository navigation
Cork the timer writes in ServerSentEvents.js example - #1307
Merged
Merged
Conversation
The interval callback writes to the response outside of any uWS callback, so every event printed "Warning: uWS.HttpResponse writes must be made from within a corked callback". Wrap the write in res.cork(), the same way VideoStreamer.js was fixed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I ran examples/ServerSentEvents.js against the current Linux x64 binaries and streamed it with
curl -N. The client gets its events, but the server prints this once per event:The
res.writeruns from asetInterval, which is outside any uWS callback, so it is never corked. This is the same thing that was fixed in VideoStreamer.js in 0b33a99. I wrapped the write inres.cork().To check, I ran the example for 3.5 seconds with curl attached. Before the change the client got 3 events and there were 3 warnings on stderr. After it, still 3 events and no warnings.
AI tools used