Azure / Azure/fetch-event-source
fetchEventSource() repeats request indefinitely
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
I have SSE-endpoint `http://localhost/sse-endpoint` that returns next data:
```
data:{text: "He"}
id:0
data:{text: "ll"}
id:2
data:{text: "o,"}
id:4
data:{text: " u"}
id:6
data:{text: "se"}
id:8
data:{text: "r!"}
id:10
```
I use this client code to fetch data:
```js
import { fetchEventSource } from "@microsoft/fetch-event-source";
console.log('Start');
fetchEventSource("http://localhost/sse-endpoint"), {
method: "POST",
onmessage(ev) {
console.log('Received data');
console.log(ev.data);
}
});
```
Expected output:
```
Start
Received data
{text: "He"}
Received data
{text: "ll"}
Received data
{text: "o,"}
Received data
{text: " u"}
Received data
{text: "se"}
Received data
[{text: "r!"}
```
Actual output:
```
Start
Received data
{text: "He"}
Received data
{text: "ll"}
Received data
{text: "o,"}
Received data
{text: " u"}
Received data
{text: "se"}
Received data
[{text: "r!"}
Received data
{text: "He"}
Received data
{text: "ll"}
Received data
{text: "o,"}
Received data
{text: " u"}
Received data
{text: "se"}
Received data
[{text: "r!"}
// Output continues infinitely
```
In devtools tab "Network" I can see that requests to `/sse-endpoint` continues indefinitely
Contributor guide
Assessment
This issue has not been assessed yet.