-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix WS/SSE tests and replace go backend with NodeJS #1876
Conversation
089ef11
to
c888ce8
Compare
be4bd74
to
5c73965
Compare
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.
LGTM
Hey, this looks really cool. And Javascript will probably be a better / more portable environment to do this than Go has been. Awesome work :) |
That means a lot, thank you Ben :) |
Amazing work. Perhaps it is irrelevant for these purposes, but https://github.com/uNetworking/uWebSockets.js/ is known to be by far the fastest/most powerful nodejs websockets library. It might be worth taking a look, as it would be a useful tool for production as well. The author's blog is quite informative (if inflammatory at times). https://unetworkingab.medium.com/the-story-of-uws-so-far-493ac0c05ccb Here's another good one as well https://edisonchee.com/writing/intro-to-%C2%B5websockets.js/ |
@nickchomey That's great to know, these are good reads. I do think for the test purposes that I'll stick with |
Background
The live WebSocket/Server-Side Events tests were causing us a couple problems:
So, to the fix the dependabot thing and partially as an excuse to learn what WebSockets are, I reimplemented the tests' backend in NodeJS.
Description
The main changes are as follows:
hx-boost
andhx-get
, so now refreshing the page takes you back the tab you were on, instead of the homepage, and links are persisted in the URL bar/history. This makes developing on them much nicer.package.json
nowAnd as far as I can tell, all the tests work now! There's a couple small changes to the timing of the events that I'll play around with, but what I have now gets the job done.
Testing
Run
npm run ws-tests
from the package root! There's also a readme in/tests/ws-sse
directory with some granular instructions.Note that the old go code is still mirrored on the website, which I left in for this PR so that the comparisons are more obvious. When we cut the next release it will go away and officially remove the the last of the go code.
Credits
Huge props to @benpate for writing the initial version of these tests. It's much easier to adapt exist code than write a whole new paradigm, and his test suite and server code was really easy to follow.