fetch-event-source
fetch-event-source copied to clipboard
A better API for making Event Source requests, with all the features of fetch()
Can it be achieved to interrupt or cancel the response during the response process
for message: "id:111111\nevent:add\ndata:\ndata:more\n\n" **before:** parse result is: ```json { id: "11111", event: "add", data: "more" } ``` **now:** parse result is: ```json { id: "11111", event: "add", data: "\nmore" }...
Basically this comment says it: https://github.com/Azure/fetch-event-source/blob/a0529492576e094374602f24d5e64b3a271b4576/src/fetch.ts#L10 It would be nice to support `Headers` as well here, as failing requests because of this problem can be quite hard to debug.
Hello , I tried the same server side code and client side with this package and default event source . i see that server is getting close event as soon...
```js fetchEventSource('https://api.openai.com/v1/chat/completions', { method: 'POST', headers: { Accept: 'text/event-stream', 'Content-Type': 'application/json', Authorization: 'Bearer ' + process.env.NEXT_PUBLIC_OPENAI_KEY, }, body: raw, signal: ctrl.signal, onopen(res) { console.log('onopen ', res); }, onmessage(evt) { console.log('msg.data',...
In the process of onmessage, switch to another pages, it will resend the request.
hi, this is my case. sometimes, call create before dispose when caught exception, but curRequestController get a new AbortController, so it doesn't work. ``` async function create() { curRequestController =...