-
Notifications
You must be signed in to change notification settings - Fork 31
fix: Make it more clear what is happening when an event source is connecting. #518
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
Conversation
| .mockImplementationOnce(() => 0.888) | ||
| .mockImplementationOnce(() => 0.999); | ||
|
|
||
| mockXhr = { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
🤖 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>
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.