mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
# Backport This will backport the following commits from `main` to `9.0`: - [[SSE] Fix EventSource streams (#213151)](https://github.com/elastic/kibana/pull/213151) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Alejandro Fernández Haro","email":"alejandro.haro@elastic.co"},"sourceCommit":{"committedDate":"2025-03-11T10:33:11Z","message":"[SSE] Fix EventSource streams (#213151)\n\n## Summary\n\nResolves #212919\n\nWe noticed that setting the header `'Content-Type':\n'text/event-stream',` didn't work as the browser's native EventSource\nimplementation.\n\n```JS\n return res.ok({\n headers: {\n 'Content-Type': 'text/event-stream',\n 'Cache-Control': 'no-cache',\n },\n body: observableIntoEventSourceStream(events$ as unknown as Observable<ServerSentEvent>, {\n signal: abortController.signal,\n logger,\n }),\n });\n```\n\nThe reason, apparently, is that we need to flush the compressor's buffer\nnegotiated in the HTTP request.\n\n### How to test it:\n\nRun Kibana with examples `yarn start --no-base-path --run-examples\n--http2` and open the SSE example app in Kibana. You should see a clock\nupdating every second in the UI (the clock is coming from the server).\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"bdf7823c54b784699cabc364e8b33bd1d5a64d2f","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","backport:prev-minor","v9.1.0"],"title":"[SSE] Fix EventSource streams","number":213151,"url":"https://github.com/elastic/kibana/pull/213151","mergeCommit":{"message":"[SSE] Fix EventSource streams (#213151)\n\n## Summary\n\nResolves #212919\n\nWe noticed that setting the header `'Content-Type':\n'text/event-stream',` didn't work as the browser's native EventSource\nimplementation.\n\n```JS\n return res.ok({\n headers: {\n 'Content-Type': 'text/event-stream',\n 'Cache-Control': 'no-cache',\n },\n body: observableIntoEventSourceStream(events$ as unknown as Observable<ServerSentEvent>, {\n signal: abortController.signal,\n logger,\n }),\n });\n```\n\nThe reason, apparently, is that we need to flush the compressor's buffer\nnegotiated in the HTTP request.\n\n### How to test it:\n\nRun Kibana with examples `yarn start --no-base-path --run-examples\n--http2` and open the SSE example app in Kibana. You should see a clock\nupdating every second in the UI (the clock is coming from the server).\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"bdf7823c54b784699cabc364e8b33bd1d5a64d2f"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/213151","number":213151,"mergeCommit":{"message":"[SSE] Fix EventSource streams (#213151)\n\n## Summary\n\nResolves #212919\n\nWe noticed that setting the header `'Content-Type':\n'text/event-stream',` didn't work as the browser's native EventSource\nimplementation.\n\n```JS\n return res.ok({\n headers: {\n 'Content-Type': 'text/event-stream',\n 'Cache-Control': 'no-cache',\n },\n body: observableIntoEventSourceStream(events$ as unknown as Observable<ServerSentEvent>, {\n signal: abortController.signal,\n logger,\n }),\n });\n```\n\nThe reason, apparently, is that we need to flush the compressor's buffer\nnegotiated in the HTTP request.\n\n### How to test it:\n\nRun Kibana with examples `yarn start --no-base-path --run-examples\n--http2` and open the SSE example app in Kibana. You should see a clock\nupdating every second in the UI (the clock is coming from the server).\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"bdf7823c54b784699cabc364e8b33bd1d5a64d2f"}}]}] BACKPORT--> Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co> |
||
---|---|---|
.. | ||
common | ||
public | ||
server | ||
kibana.jsonc | ||
README.md | ||
tsconfig.json |
SSE Example
This plugin's goal is to demonstrate how to implement Server-Sent Events.