Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The data is logged only after the stream ends. #26

Closed
CelestialAzure opened this issue Aug 30, 2023 · 6 comments
Closed

The data is logged only after the stream ends. #26

CelestialAzure opened this issue Aug 30, 2023 · 6 comments

Comments

@CelestialAzure
Copy link

CelestialAzure commented Aug 30, 2023

The server sent stream data is only logged on console once the entire stream ends. Not sure how to go about fixing this.

  • Code Sample -
    const url = new URL("....");
    const es = new EventSource(url, {
    headers: {
    "Content-Type": "application/json",
    Accept: "text/event-stream",
    "X-SS-API-KEY": "",
    "X-SSUID": "",
    "X-SSPID": "",
    Authorization: bearer ${token},
    Connection: "keep-alive",
    },
    method: "POST",
    body: JSON.stringify(data),
    pollingInterval: 10000,
    timeout: 10000,
    });

es.addEventListener("message", e => {
console.log("message:", JSON.parse(e.data));
});

@antondrob
Copy link

@CelestialAzure did you fix this issue? I experience the same one.

@antondrob
Copy link

The problem is with Flipper. This will fix the issue facebook/react-native#28835 (comment)

@BuddhaBing
Copy link

I have the same issue on iOS

@pokaru
Copy link

pokaru commented Mar 16, 2024

I'm guessing the fix is still underway?

@EmilJunker
Copy link
Contributor

EmilJunker commented Mar 16, 2024

I'm guessing the fix is still underway?

The problem is not on our side. We cannot fix it. As it stands, any kind of SSE connections (regardless of which library you use) will not work in React Native debug builds on Android.

Here is what you can do:

A) Build your app in release mode. The SSE connection should work just fine then.

B) Disable Flipper by commenting out the corresponding lines of code in some Java/Kotlin file located under the android folder of your project. The exact location depends on the React Native version you're using. In newer versions of React Native, I think it's somewhere in the MainActivity or MainApplication file. Once you've commented out Flipper, SSE should work also in debug builds.

C) Possibly wait for the next major release of React Native which (if I understand it correctly) will no longer include Flipper by default, so there is a chance this issue will just resolve itself: https://reactnative.dev/blog/2023/12/06/0.73-debugging-improvements-stable-symlinks#flipper--react-native-integration

@pokaru
Copy link

pokaru commented Mar 17, 2024

@EmilJunker, thanks for the info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants