reactioncommerce / reaction

Mailchimp Open Commerce is an API-first, headless commerce platform built using Node.js, React, GraphQL. Deployed via Docker and Kubernetes.
https://mailchimp.com/developer/open-commerce/
GNU General Public License v3.0
12.34k stars 2.17k forks source link

Prevent publishing all Products for non-admin user, it breaks the app for large product sets. #3662

Closed prinzdezibel closed 6 years ago

prinzdezibel commented 6 years ago

Expected behavior

Navigation should be snappy and fast, regardless of the number of products that are available in shop. Browser should not freeze at any time.

Actual behavior

When having 1000 or more products, the app becomes unusable. Navigating to the index route (or tag route) will take minutes before it gets displayed. On many occasions it freezes and the browser tab becomes unresponsive.

Steps to reproduce the behavior

  1. Clone reaction-devtools into /imports/plugins/custom

    $ cd import/plugins/custom
    $ git clone https://github.com/reactioncommerce/reaction-devtools.git
  2. Reset database and start

    $ reaction reset -n
    $ reaction
  3. Login as admin and open developer tools Load medium dataset. see screenshot. reaction

  4. Logout

  5. As non-admin user, navigate to http://localhost:3000

  6. Wait for a long time to see the products to appear. Sometimes the page doesn't load at all.

Finding a solution for this issue would involve reviewing this code: https://github.com/reactioncommerce/reaction/blob/f40ff536c139d70da02ca10ae12655247452d658/server/publications/collections/products.js#L539-L542

spencern commented 6 years ago

@prinzdezibel do you have any indication as to what is causing this performance decrease? Is this related to the issue with the product grid publication performance #3368

prinzdezibel commented 6 years ago

@spencern The reason for that is the fact, that all products are published to client.

See also the code in products.js linked above. For non-admin users, limit:productScrollLimit is commented out.

The test instructions from the ticket #3368 read:

  • As an admin, import products from Shopify. Observe that the number of products published is limited to the set scroll limit (24 by default)
  • Publish a bunch of products and visit as a guest - observe that the number of products published is limited to the set scroll limit.

I can confirm the first point, but not the second. That seems not to hold true in current code base.

prinzdezibel commented 6 years ago

@spencern This happens in master branch. maybe I'm missing something?

aldeed commented 6 years ago

Whoever tackles this, be sure to start from feat-1221-aldeed-npm-cfs branch if it is not merged to master yet. In that branch, I've dealt with the media portion of this slowness, separating it from product publication and instead letting the client request the media it needs as products arrive on the client.

aldeed commented 6 years ago

@spencern I removed the "blocked by" as the file-collections branch is stable enough to use as the base for this ticket even if it hasn't been merged yet.