The endpoint passes ctx.RequestAborted directly to subscription.Reader.ReadAllAsync(ct). In this case, the request is a 499 Client Closed Request, meaning the client disconnected first. A deeper issue is that for this request, currentItems.Count == 0 and ctx.Response.HasStarted == false, indicating that the endpoint was waiting silently for new events without starting the response or sending the first SSE frame/heartbeat. Consequently, the connection stays in a “silent wait” state, and when the client cancels, reconnects, navigates away, or times out, RequestAborted is triggered, causing the cancellation exception to be thrown at the await foreach loop. Since the code does not catch this cancellation, the debugger treats it as an unhandled exception.
The endpoint passes ctx.RequestAborted directly to subscription.Reader.ReadAllAsync(ct). In this case, the request is a 499 Client Closed Request, meaning the client disconnected first. A deeper issue is that for this request, currentItems.Count == 0 and ctx.Response.HasStarted == false, indicating that the endpoint was waiting silently for new events without starting the response or sending the first SSE frame/heartbeat. Consequently, the connection stays in a “silent wait” state, and when the client cancels, reconnects, navigates away, or times out, RequestAborted is triggered, causing the cancellation exception to be thrown at the await foreach loop. Since the code does not catch this cancellation, the debugger treats it as an unhandled exception.