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

Add pinghub handler to wpcom-xhr-wrapper #45863

Closed
wants to merge 1 commit into from

Conversation

jsnajdr
Copy link
Member

@jsnajdr jsnajdr commented Sep 23, 2020

Add pinghub support for WebSocket connections to wpcom-xhr-wrapper, the wpcom handler used by Desktop app. The Desktop app uses OAuth and doesn't use the REST proxy iframe.

The pinghub handler intercepts requests to /pinghub/* paths and instead of making HTTP requests (XHR or fetch), handles them specially with WebSockets. In the web version of Calypso, this is done by the REST proxy provider loaded in the iframe.

This code doesn't fully work yet, it's just a proof of concept that shows what needs to be done to make Pinghub WebSockets work in Desktop app.

@jsnajdr jsnajdr added the [Feature] WordPress Desktop App Features and improvements related to the WordPress Desktop App. label Sep 23, 2020
@jsnajdr jsnajdr self-assigned this Sep 23, 2020
@matticbot
Copy link
Contributor

@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Sep 23, 2020
@matticbot
Copy link
Contributor

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~1265 bytes added 📈 [gzipped])

name                   parsed_size           gzip_size
entry-main                  +946 B  (+0.1%)     +318 B  (+0.1%)
entry-login                 +946 B  (+0.1%)     +311 B  (+0.1%)
entry-gutenboarding         +946 B  (+0.1%)     +319 B  (+0.1%)
entry-domains-landing       +946 B  (+0.2%)     +317 B  (+0.2%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@nsakaimbo
Copy link
Contributor

nsakaimbo commented Sep 23, 2020

Thanks for putting this PR together! Overall makes sense and looks reasonable. Couple quick clarifications for my own education:

  1. Is the intention for this logic to "just work" and intercept the existing call to pinghub in the notifications rest client? (I think the answer is "yes" but didn't want to take any details for granted!)

  2. Per the proposal in your deep-dive, this would need to be augmented with the OAuth token, yeah? (Assuming the backend will support it?)

@jsnajdr
Copy link
Member Author

jsnajdr commented Sep 24, 2020

Is the intention for this logic to "just work" and intercept the existing call to pinghub in the notifications rest client?

Yes, it will intercept all requests to /pinghub/* and instead of issuing a HTTP request, it will interpret the request as WebSocket processing.

Per the proposal in your deep-dive, this would need to be augmented with the OAuth token, yeah?

Yes, the patch is not finished yet. I didn't add the token to URL, because I have no way to test it. Also, I think the format of responses sent to the callback will need to be different. Instead of { body: { type }, code } it will be { response: { type }, code }? With no way to test it against a real server, I don't know.

@jsnajdr
Copy link
Member Author

jsnajdr commented Nov 2, 2020

An alternative solution to the issue was merged in #46070. This one can be closed.

@jsnajdr jsnajdr closed this Nov 2, 2020
@jsnajdr jsnajdr deleted the add/wpcom-pinghub-handler branch November 2, 2020 07:26
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] WordPress Desktop App Features and improvements related to the WordPress Desktop App.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants