kibana/examples/sse_example
Alejandro Fernández Haro bdf7823c54
[SSE] Fix EventSource streams (#213151)
## Summary

Resolves #212919

We noticed that setting the header `'Content-Type':
'text/event-stream',` didn't work as the browser's native EventSource
implementation.

```JS
      return res.ok({
        headers: {
          'Content-Type': 'text/event-stream',
          'Cache-Control': 'no-cache',
        },
        body: observableIntoEventSourceStream(events$ as unknown as Observable<ServerSentEvent>, {
          signal: abortController.signal,
          logger,
        }),
      });
```

The reason, apparently, is that we need to flush the compressor's buffer
negotiated in the HTTP request.

### How to test it:

Run Kibana with examples `yarn start --no-base-path --run-examples
--http2` and open the SSE example app in Kibana. You should see a clock
updating every second in the UI (the clock is coming from the server).

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2025-03-11 11:33:11 +01:00
..
common [SSE] Fix EventSource streams (#213151) 2025-03-11 11:33:11 +01:00
public [SSE] Fix EventSource streams (#213151) 2025-03-11 11:33:11 +01:00
server [SSE] Fix EventSource streams (#213151) 2025-03-11 11:33:11 +01:00
kibana.jsonc [SSE] Fix EventSource streams (#213151) 2025-03-11 11:33:11 +01:00
README.md [SSE] Fix EventSource streams (#213151) 2025-03-11 11:33:11 +01:00
tsconfig.json [SSE] Fix EventSource streams (#213151) 2025-03-11 11:33:11 +01:00

SSE Example

This plugin's goal is to demonstrate how to implement Server-Sent Events.