Azure / fetch-event-source

A better API for making Event Source requests, with all the features of fetch()
MIT License
1.78k stars 137 forks source link

connection close event is fired shortly after connection #30

Open khirod-dev opened 1 year ago

khirod-dev commented 1 year ago

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 as connection is established . Just to make sure that my Server side code is not the issue I changed the client code to native event source and i cam seeing that it works as expected . i am interested to send header and other good things that this Package has . Can any one help me

My client side code (removed all other codes just to keep simple ) wrapped in useEffect reactHook

const fetchData = async () => {
      await fetchEventSource(`${serverBaseURL}`, {
        method: "POST",
        body: JSON.stringify({ userName, uniqueUserIdentifier }),
        headers: {
          Accept: "text/event-stream",
        },

        openWhenHidden: true,
        onclose() {
          console.log("Connection closed by the server");
        },
      });
    };
    fetchData();
  }, []);
jiraiyame commented 1 year ago

any update for this issue? i have the same prob

aurerere commented 11 months ago

same prob too