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

Cart vanishes when the shell is restarted (OCC-276) #475

Open
Piedone opened this issue Aug 1, 2024 · 2 comments
Open

Cart vanishes when the shell is restarted (OCC-276) #475

Piedone opened this issue Aug 1, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Piedone
Copy link
Member

Piedone commented Aug 1, 2024

Describe the bug

If you have items in the cart, a shell restart will wipe it out. This is an issue because configuration changes, deployments can cause the shell to restart at any time, but this disrupts shopping and causes the shop to lose money.

To Reproduce

  1. Launch the latest main (9d3d685).
  2. Add something to the cart.
  3. Enable any feature. For the sake of simplicity, I enabled the harmless Background Tasks one.
  4. Observer that after a refresh on the frontend, the contents of the cart are gone.

Expected behavior

The cart remains after a shell restart too.

Screenshots

2024-08-01_23h08_05.mp4

Jira issue

@Piedone Piedone added the bug Something isn't working label Aug 1, 2024
@github-actions github-actions bot changed the title Cart vanishes when the shell is restarted Cart vanishes when the shell is restarted (OCC-276) Aug 1, 2024
@sarahelsaig
Copy link
Contributor

sarahelsaig commented Aug 1, 2024

This is not a bug. The reference implementation of IShoppingCartPersistence is SessionShoppingCartPersistence. This serializes the cart contents into HttpContext.Session, which is volatile storage that's lost when the application closes.

The advantage of this temporary storage is both ease of implementation and not having to worry about invalidating and periodically cleaning up abandoned carts (otherwise abandoned carts could accidentally or maliciously eat up the site's database space). The disadvantage is what you described. However config changes and deployments shouldn't happen so often where this becomes a realistic problem in everyday use, so session storage remains a suitable default.

Web developers using OCC can implement their own IShoppingCartPersistence which uses site setting, an external database, etc for persistent storage. A purely client side storage is also an option. We may add a different implementation as a feature in the future. The added complication and the unclear demand makes me less convinced that this should be a priority. But if desired, please convert this from bug to a feature issue.

@Piedone
Copy link
Member Author

Piedone commented Aug 1, 2024

Really every user-facing feature needs to be resilient so shell restarts in an OC app (as it is with the OOTB features, like user logins remain, and you can edit content items without disruption), since a shell restart is not at all uncommon. It happens e.g. in the following scenarios:

  • A lot of site settings and other configuration changes restart the shell apart from turning features on or off.
  • On DotNest, we shut down idle tenants. If you start shopping, get up to do whatever, then come back later to finish it, you might hit a now newly starting shell.
  • In an actively developed app deployments and prod rollouts can happen daily, or even multiple times a day. (There are periods like this in our apps too.)

And furthermore, horizontal scaling should be possible to support as well.

I don't think the current implementation is really appropriate, then.

@Piedone Piedone added enhancement New feature or request and removed bug Something isn't working labels Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants