Skip to content

Conversation

@kinyoklion
Copy link
Member

The event source was treating the initial connection as a re-connection. This results in confusing messaging.

This also changes the retrying event, which we do not expose.

When we convert our polyfill to typescript we should use it instead and allow passing a connection method. The reason this is being used is theoretically an issue with fetch not streaming in RN, so it uses an XHR instead.

.mockImplementationOnce(() => 0.888)
.mockImplementationOnce(() => 0.999);

mockXhr = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a mock XHR so it makes the request to this instead of a general request.
I did this because I made the event source open method private, because it should be private.

We should make these tests respond to the XHR responses instead of directly manipulating the event source, but that was out of scope for the problem I wanted to resolve.

private url: string;
private xhr: XMLHttpRequest = new XMLHttpRequest();
private pollTimer: any;
private connectTimer: any;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the name to reflect what it is doing.

}

this.connectTimer = setTimeout(() => {
if(!initialConnection) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to close for the first connection.

@kinyoklion kinyoklion marked this pull request as ready for review July 17, 2024 23:19
@kinyoklion kinyoklion requested a review from a team as a code owner July 17, 2024 23:19
@kinyoklion kinyoklion merged commit 52055ba into main Jul 18, 2024
@kinyoklion kinyoklion deleted the rlamb/react-event-source-connection-logging branch July 18, 2024 19:48
@github-actions github-actions bot mentioned this pull request Jul 18, 2024
kinyoklion added a commit that referenced this pull request Jul 22, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>react-native-client-sdk: 10.3.0</summary>

##
[10.3.0](react-native-client-sdk-v10.2.1...react-native-client-sdk-v10.3.0)
(2024-07-19)


### Features

* Update expo and RN version used in example.
([#520](#520))
([b8384c4](b8384c4))


### Bug Fixes

* Make it more clear what is happening when an event source is
connecting. ([#518](#518))
([52055ba](52055ba))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

4 participants