spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.32k stars 38.01k forks source link

Commit a2ef6ba breaks SseEmitter because of incorrect newline character #29459

Closed alexm76x closed 1 year ago

alexm76x commented 1 year ago

The following commit https://github.com/spring-projects/spring-framework/commit/a2ef6badc4c76790128910851fdde0df55ec15f9 causes SseEmitter to use \n as newline character on Linux systems. However, for SSE the HTML standard clearly requires newline characters to be \r\n https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream This causes the browser SSE client to stop raising "onmessage" event in EventSource when used with Spring MVC server. Tested on Edge and Firefox.

jhoeller commented 1 year ago

That commit has not changed any of the characters materially, just using char instead of String values for them. I'm wondering why that could have caused an actual difference in the output...

As for the SSE spec, I'm reading it as alternatives: either CR LF or just CR or just LF. Could you please double-check what kind of effect you are seeing there, and whether it actually is a regression from earlier Spring Framework versions?

alexm76x commented 1 year ago

I'm terribly sorry, this is false alarm. The problem turned out to be with my JS client code.