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

wpcom-proxy-request: Return Promise if no callback specified (Take 3) #39825

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented Mar 3, 2020

Reverts #39823
Take 3 of #39683:

Changes proposed in this Pull Request

The promise wrapper introduced by @andrewserong et al. in #38823 seems generic enough for it to make sense to have it in wpcom-proxy-request. This PR moves it there. This follows precedent set by wpcom.js.

Note that this is a technically a breaking change, as noted in the package's History.md:

  • [...] Return Promise (rather than XMLHttpRequest instance) if no callback argument is provided.

    • In practice, most people have probably been using the callback rather than the returned XMLHttpRequest instance, so this shouldn't be a breaking change for most.

Testing instructions

Verify that Gutenboarding still works (esp account and site creation).

Conflicting changes had been merged in the interim. I've updated the imports to fix the issue from #39722

@matticbot
Copy link
Contributor

matticbot commented Mar 3, 2020

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

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

name                   parsed_size           gzip_size
entry-main                  +235 B  (+0.0%)      +87 B  (+0.0%)
entry-login                 +235 B  (+0.0%)      +79 B  (+0.0%)
entry-jetpack-cloud         +235 B  (+0.0%)      +81 B  (+0.0%)
entry-domains-landing       +235 B  (+0.0%)      +78 B  (+0.0%)
entry-gutenboarding         +165 B  (+0.0%)      -10 B  (-0.0%)

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.

Comment on lines +19 to 23
jest.mock( 'wpcom-proxy-request', () => ( {
__esModule: true,
default: jest.fn(),
requestAllBlogsAccess: jest.fn( () => Promise.resolve() ),
} ) );
Copy link
Member Author

Choose a reason for hiding this comment

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

A centralized set of generic controls for wpcom-proxy-request and generic fetch could make this testing easier.

Copy link
Contributor

Choose a reason for hiding this comment

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

Follow-up material maybe? 😬

@sirreal sirreal marked this pull request as ready for review March 3, 2020 11:28
@sirreal sirreal requested review from a team as code owners March 3, 2020 11:28
@sirreal
Copy link
Member Author

sirreal commented Mar 3, 2020

I've pushed fixes for the issues introduced by merge, the auth store work was incompatible with the other changes from this branch.

This should be ready to land now.

@sirreal sirreal requested a review from a team March 3, 2020 11:29
@sirreal sirreal added [Goal] New Onboarding previously called Gutenboarding API Data Packages [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Mar 3, 2020
Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

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

Third time's a charm! 🍀 🤞

@ockham ockham merged commit af0d7ff into master Mar 3, 2020
@ockham ockham deleted the revert-39823-revert-39722-revert-39721-revert-39683-add/wpcom-proxy-request-promise-return branch March 3, 2020 15:56
@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 Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants