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

Streaming: Rework websocket server initialisation & authentication code #28631

Conversation

ThisIsMissEm
Copy link
Contributor

This moves us away from the deprecated verifyClient mechanism, to using a custom 'upgrade' event handler as recommended by the author of the ws module.

In the future, we should probably move towards using a custom WebSocket subclass to add in additional methods and data directly to the WebSocket instance, by passing the WebSocket option, which would give a cleaner abstraction for the logger and other data we may want to attach to the websocket, such as isAlive — you can see what that'll look like in this branch: https://github.com/mastodon/mastodon/compare/main...ThisIsMissEm:mastodon:experimental/custom-eventsource-and-websocket-classes?expand=1

streaming/index.js Outdated Show resolved Hide resolved
@ThisIsMissEm ThisIsMissEm force-pushed the refactor/streaming-server-initialisation-and-authentication branch from 9945fb3 to cab6f7a Compare January 6, 2024 20:41
streaming/index.js Outdated Show resolved Hide resolved
streaming/index.js Outdated Show resolved Hide resolved
streaming/index.js Outdated Show resolved Hide resolved
streaming/index.js Outdated Show resolved Hide resolved
streaming/index.js Outdated Show resolved Hide resolved
@ThisIsMissEm ThisIsMissEm force-pushed the refactor/streaming-server-initialisation-and-authentication branch from cab6f7a to 0818b51 Compare January 8, 2024 19:14
@ClearlyClaire
Copy link
Contributor

Looks fine overall, but I'd prefer keeping the requestId stuff for now, especially since it's still used in places…

@ThisIsMissEm
Copy link
Contributor Author

Looks fine overall, but I'd prefer keeping the requestId stuff for now, especially since it's still used in places…

I hear you, but there's a reason this was originally all done in the logging change, because these are all strongly related, imo.

@ClearlyClaire
Copy link
Contributor

ClearlyClaire commented Jan 10, 2024

Looks fine overall, but I'd prefer keeping the requestId stuff for now, especially since it's still used in places…

I hear you, but there's a reason this was originally all done in the logging change, because these are all strongly related, imo.

I still don't understand why it's part of this commit and not the other one… I don't understand what requires the requestId definition to be removed from this commit.

@ThisIsMissEm
Copy link
Contributor Author

@ClearlyClaire just to clarify, are you saying this won't be merged as long as the request ID changes are in here? And that you want me to spend 30-60 minutes to pick those out just to do them in another already opened pull request that this was split from at Renauld's request?

Because that's going to delay being able to move forwards with this until I have the time & energy to do those additional changes.

@ClearlyClaire
Copy link
Contributor

ClearlyClaire commented Jan 11, 2024

I prefer if we don't add an unnecessary regression, however small and temporary. I can try and take this PR over if you prefer.

This moves us away from the deprecated verifyClient mechanism, towards using a
custom 'upgrade' event handler as recommended by the author of the ws module.

In the future, we could even move towards using a custom WebSocket subclass to
add in additional methods and data directly to the WebSocket instance.
@ThisIsMissEm ThisIsMissEm force-pushed the refactor/streaming-server-initialisation-and-authentication branch from 0818b51 to bc5931b Compare January 13, 2024 19:53
Copy link

codecov bot commented Jan 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (557c27e) 84.77% compared to head (bc5931b) 84.84%.
Report is 56 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #28631      +/-   ##
==========================================
+ Coverage   84.77%   84.84%   +0.06%     
==========================================
  Files        1039     1038       -1     
  Lines       28162    28152      -10     
  Branches     4541     4534       -7     
==========================================
+ Hits        23875    23886      +11     
+ Misses       3129     3103      -26     
- Partials     1158     1163       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ThisIsMissEm
Copy link
Contributor Author

@ClearlyClaire have finished rebasing this, and also #27828 — hopefully these are both good to go now.

@ClearlyClaire ClearlyClaire added this pull request to the merge queue Jan 15, 2024
Merged via the queue into mastodon:main with commit 58830be Jan 15, 2024
29 checks passed
@renchap renchap added the streaming Streaming server label Jan 15, 2024
mjankowski pushed a commit to mjankowski/mastodon that referenced this pull request Jan 15, 2024
@ThisIsMissEm ThisIsMissEm deleted the refactor/streaming-server-initialisation-and-authentication branch January 16, 2024 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
streaming Streaming server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants