Skip to content

feat: Replace socket.io-client #99

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

Merged
merged 56 commits into from
May 23, 2023
Merged

feat: Replace socket.io-client #99

merged 56 commits into from
May 23, 2023

Conversation

gismya
Copy link
Contributor

@gismya gismya commented Apr 19, 2023

  • I have added automatic tests where applicable
  • The PR title is suitable as a release note
  • The PR contains a description of what has been changed
  • The description contains manual test instructions

Changes

Removes the old socket.io client and writes a new implementation using the same communication protocol. Re-implements the parts that we were using, and scraps the rest. None of the removed parts were documented, but it was parts that might have been found by people implementing the API, so it will be released as a part of the V2 release with other breaking changes.

Resolves #90

Test

Make sure the code looks good and the test cases seem to cover everything we need. Functionality can be tested in the application by yarn linking.

@gismya gismya requested a review from a team as a code owner April 19, 2023 02:17
@gismya gismya marked this pull request as draft April 19, 2023 02:18
args: [eventData],
};
const dataString = eventData ? `:::${JSON.stringify(payload)}` : "";
this.ws?.send(`${PACKET_TYPES.event}${dataString}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

it feels a bit wrong to do nothing if the ws isn't initialized. what did the previous client do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't think it was handled, the event_hub code does unsent event queueing. But I can investigate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a simple queue

@gismya
Copy link
Contributor Author

gismya commented May 12, 2023

I think I've fixed the reconnect behavior now, but didn't have time to properly test it. I'll also have to look at the code again later to see if it needs to be cleaned up.

@ffMathy
Copy link
Contributor

ffMathy commented May 13, 2023

That's awesome stuff! I'll throw an additional review at it ASAP.

@gismya gismya marked this pull request as ready for review May 13, 2023 23:29
@ffMathy
Copy link
Contributor

ffMathy commented May 15, 2023

LGTM! 😍

@@ -0,0 +1,32 @@
import { EventHub } from "../source/event_hub";

Choose a reason for hiding this comment

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

Missing Copyright text

@gismya gismya changed the base branch from main to release/v2 May 15, 2023 12:14
@gismya gismya linked an issue May 15, 2023 that may be closed by this pull request
Copy link
Contributor

@ffMathy ffMathy left a comment

Choose a reason for hiding this comment

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

Only one minor comment.

@@ -247,7 +237,7 @@ export class EventHub {
*
* If timeout is non-zero, the promise will be rejected if the event is not
* sent before the timeout is reached. Should be specified as seconds and
* will default to 10.
* will default to 30.
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this a breaking change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was simply my noticing that the comment was incorrect.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah okay. All good then!

"vite": "^4.2.2",
"vite-plugin-dts": "^2.3.0",
"vitest": "^0.30.1",
"ws": "^8.13.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove unrelated dependency upgrades and make them in a separate PR

@gismya gismya changed the base branch from release/v2 to main May 19, 2023 12:19
@gismya gismya force-pushed the rewrite-socketio-client branch from 68c2591 to c4f2e24 Compare May 19, 2023 12:23
@jimmycallin jimmycallin changed the title feat!: Replace socket.io-client feat: Replace socket.io-client May 19, 2023
@gismya gismya force-pushed the rewrite-socketio-client branch from c4f2e24 to a7834e5 Compare May 22, 2023 07:58
@ffMathy
Copy link
Contributor

ffMathy commented May 22, 2023

Loving the progress so far! We're cheering for you in my team. Keep up the good work! ❤️

@gismya gismya merged commit ceb68a7 into main May 23, 2023
@gismya gismya deleted the rewrite-socketio-client branch May 23, 2023 10:08
@ffMathy
Copy link
Contributor

ffMathy commented May 23, 2023

Yaaaay!

lucaas added a commit that referenced this pull request May 26, 2023
lucaas added a commit that referenced this pull request May 26, 2023
* Revert "fix(test): Fix Math.random flaky test (#108)"

This reverts commit 0a140a7.

* Revert "feat: Replace socket.io-client (#99)"

This reverts commit ceb68a7.
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.

What is preventing Event Hub from working in Node?
4 participants