ServerSentEvents should return headers immediately? #68734
Replies: 2 comments 1 reply
|
The observed behavior follows the current implementation. For the simple case, yield an initial event or heartbeat before the 30-second delay: async IAsyncEnumerable<string> GenerateEvents()
{
yield return "connected";
await Task.Delay(TimeSpan.FromSeconds(30));
// subsequent events
}If the connection must start without an event, use a manual endpoint/result: set the headers, disable buffering, call |
|
Unfortunately, this behavior is unlikely to change. Applications can set headers at the top of their |

Unfortunately, this behavior is unlikely to change. Applications can set headers at the top of their
IAsyncEnumerable, any changes to when we flush headers would be breaking.