Skip to content

Cork the timer writes in ServerSentEvents.js example - #1307

Merged
uNetworkingAB merged 1 commit into
uNetworking:masterfrom
Dev-next-gen:examples-sse-cork
Sep 13, 2026
Merged

uNetworkingAB merged 1 commit into
uNetworking:masterfrom
Dev-next-gen:examples-sse-cork

Conversation

@Dev-next-gen

Copy link
Copy Markdown
Contributor

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:

Warning: uWS.HttpResponse writes must be made from within a corked callback. See documentation for uWS.HttpResponse.cork and consult the user manual.

The res.write runs from a setInterval, 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 in res.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

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.
@uNetworkingAB
uNetworkingAB merged commit 690d980 into uNetworking:master Sep 13, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants