Openfoodnetwork: Broken shopfront in an edge case where OC is closed but products are fetched from database

Created on 5 May 2020  路  7Comments  路  Source: openfoodfoundation/openfoodnetwork

Error in OpenFoodNetwork UK

AbstractController::DoubleRenderError in api/order_cycles#products
Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".

View on Bugsnag

Stacktrace

app/controllers/api/base_controller.rb:74 - error_during_processing

View full stacktrace

Created by Admin OFF via Bugsnag

bug-s3 bugsnag

Most helpful comment

Is it a bug or a feature? :rofl:

All 7 comments

bug introduced in this release:
https://github.com/openfoodfoundation/openfoodnetwork/pull/5315/files#r420067156

We are not sure how edgy this case is: 1 user impacted in UK and 1 user in AUS. It's a very easy fix so I think we should get a release out to fix this.

I've investigated this a bit more closely, and looked at the exact order cycles that were visited on UK and AUS Prod servers. It looks like they closed part-way through somebody shopping (the hub reached their order limit and manually shut the shop in the UK case).

Looking at the code as well, I think this issue only affects closed order cycles, and the result of the error is just that we don't load any more products from the product list endpoint after the order cycle has closed.

So I think this is actually not an emergency, it basically will not really impact users. We can fix it for sure, but it's not the end of the world.

Is it a bug or a feature? :rofl:

So if I understand correctly: it's the case of customer adding stuff to their card and navigating through the products => But bim, the shop owner decide to close earlier... So the "fix" would make sure we gracefully re-direct the user to the shop close message if he tries to add a product to cart or something equivalent?

Yes, the hub closed the OC while someone was shopping, and they scrolled down through the products, and it did not load more products.

I think we actually already redirect the user to the homepage with a "this order cycle has closed" message (it happened to me when I tried to check those affected order cycles). Maybe that happened as well, shortly after the products failed to load?

ok, great Matt, that makes sense.
I tagged S2 assuming this was a snail but you are right, this is only an ajax call that will fail. The user will not see it. The user will just not get an update of the list of products and sooner or later (probably by clicking somewhere), user is warned and redirected.
I am changing to S3.

Already fixed and in code review :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

filipefurtad0 picture filipefurtad0  路  3Comments

kristinalim picture kristinalim  路  3Comments

andrewpbrett picture andrewpbrett  路  3Comments

filipefurtad0 picture filipefurtad0  路  3Comments

sauloperez picture sauloperez  路  3Comments