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

Checkout: remove post-checkout polling for site for create_new_blog #69837

Merged
merged 3 commits into from
Nov 8, 2022

Conversation

sirbrillig
Copy link
Member

@sirbrillig sirbrillig commented Nov 7, 2022

Background

The transactions endpoint supports a property on the shopping cart object called create_new_blog. If set, the endpoint will create a new site before the transaction is processed. However, even though we set this property on the frontend for any transaction where there is no currently selected site (which should be domain-only checkout and Jetpack siteless checkout, although the latter may have a special case), it doesn't appear to be ever used on the backend to create a new site (see https://github.com/Automattic/payments-shilling/issues/759#issuecomment-1306365375). This is because logged-out and siteless flows that currently go through checkout (except for Jetpack siteless checkout which understandably does not need to create a site) create the site before the transaction is submitted.

While it may not yet be safe to remove the create_new_blog property entirely (since it may be used on the backend cart to signal that a site will be created), we can probably remove some of the machinery that uses it.

Proposed Changes

In this PR we remove code that causes some post-checkout flows (for non-redirect payment methods which have create_new_blog and a domain in the purchase) to poll the sites endpoint after the transactions endpoint returns a successful response. This code was probably intended to prevent issues where the post-checkout page would try to display information about the newly created site and fail, but I think this is unlikely ever to happen since post-checkout for new sites already causes a hard-redirect which will probably reload the sites list.

The code removed by this PR was added in #42723 which in turn imported the behavior from the old version of checkout where it was added originally in #10936. That PR was creating a flow for domain-only checkout which should not be affected by this change (although I think that flow does create a hidden site in the background so it's wise to make sure that PR's test instructions still work).

Fixes #69833 where purchasing a gift subscription for another site would cause infinite polling to occur.

Note: this also removes the getDomainNameFromReceiptOrCart() function which is no longer used anywhere.

Testing Instructions

First we can follow the test instructions for the PR that added this code to the rebuilt checkout:

  • Create a new site and select a paid domain and a paid plan during the site creation process.
  • Complete checkout during the site creation process.
  • Verify that the post-checkout flow refers to the site just created.

Second we can follow the instructions for the PR that originally added the code to make sure that domain-only checkout is unaffected:

  • Visit /start/domain/domain-only and complete the flow to purchase a new domain without a site.
  • Verify that when checkout completes, you are redirected to a post-checkout page for that domain.

@sirbrillig sirbrillig self-assigned this Nov 7, 2022
@matticbot
Copy link
Contributor

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

Sections (~443 bytes removed 📉 [gzipped])

name             parsed_size           gzip_size
checkout             -1327 B  (-0.1%)     -408 B  (-0.1%)
signup                -254 B  (-0.1%)      -35 B  (-0.1%)
jetpack-connect       -254 B  (-0.0%)      -35 B  (-0.0%)
accept-invite         -254 B  (-0.1%)      -35 B  (-0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~414 bytes removed 📉 [gzipped])

name                                             parsed_size           gzip_size
async-load-calypso-blocks-editor-checkout-modal      -1327 B  (-0.1%)     -414 B  (-0.2%)
async-load-calypso-my-sites-checkout-modal            -973 B  (-0.1%)     -295 B  (-0.1%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

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.

@sirbrillig sirbrillig marked this pull request as ready for review November 8, 2022 18:42
@sirbrillig sirbrillig requested review from a team as code owners November 8, 2022 18:42
@matticbot matticbot added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Nov 8, 2022
@pottedmeat pottedmeat self-requested a review November 8, 2022 20:25
Copy link
Contributor

@pottedmeat pottedmeat left a comment

Choose a reason for hiding this comment

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

Tested regular site creation, new user siteless domain creation, and gifted domain (which had been failing previously). All checkouts as expected.

Code looks good, though I wonder if we shouldn't keep getDomainNameFromReceiptOrCart.

@sirbrillig
Copy link
Member Author

Code looks good, though I wonder if we shouldn't keep getDomainNameFromReceiptOrCart.

The function is totally fine but it's not used anywhere. 🤷 I'm inclined to remove it and if folks need it again it can be re-added. I'll update the PR description to mention the removal to it's easier to find.

@sirbrillig sirbrillig merged commit ae1287d into trunk Nov 8, 2022
@sirbrillig sirbrillig deleted the remove/create-new-blog-post-checkout-polling branch November 8, 2022 21:40
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 8, 2022
vasyas pushed a commit that referenced this pull request Nov 9, 2022
…69837)

* Clarify post-checkout new site polling conditions

* Remove call to fetchSitesAndUser in post-checkout

* Remove unused getDomainNameFromReceiptOrCart
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.

Post-checkout redirect sometimes gets stuck in site fetching loop
3 participants