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

product not found error after creating a product due to a delay in data replica for db reader #1529

Open
simpian opened this issue Apr 21, 2022 · 2 comments
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@simpian
Copy link
Contributor

simpian commented Apr 21, 2022

Describe the bug
A clear and concise description of what the bug is.

I'm trying to setup Vendure using database replication options, however, after I set up two reader instances, and create a new product successfully, when page redirects to product page, Vendure throws product not found error. I'm thinking that this is because when Vendure redirects to product page, this is a Query request, and it goes to a reader instance, however, reader instance doesn't yet have the data replicated, so it throws product not found error.

Note: product is actually created, when I go to product list page, I can search and locate the product. This error only shows up when creating products successfully, and page automatically redirects to product page. Reader take time to replicate, but should be very quick, within 1 second. I used AWS aurora db.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Environment (please complete the following information):

  • @vendure/core version:
  • Nodejs version
  • Database (mysql/postgres etc):

Additional context
Add any other context about the problem here.

I'm thinking if we can make the following change in product-detail.component.ts

        combineLatest(this.product$, this.languageCode$)
            .pipe(
                take(1),
                mergeMap(([product, languageCode]) => {
                    const newProduct = this.getUpdatedProduct(
                        product,
                        productGroup as FormGroup,
                        languageCode,
                    ) as CreateProductInput;
                    return this.productDetailService.createProductWithVariants(
                        newProduct,
                        this.createVariantsConfig,
                        languageCode,
                    );
                }),
                delay(1000),
                retry(3)
            )

I added a delay(1000) and retry(3) to make sure that Vendure can retry 3 times after creating a product successfully before throwing the error

@simpian simpian added the type: bug 🐛 Something isn't working label Apr 21, 2022
@michaelbromley
Copy link
Member

Hi,

Thanks for the report. I'd accept a PR for this but it would need to include a comment above those 2 operators clearly explaining why they are needed, as this is quite an obscure edge-case that is non-obvious.

@martijnvdbrug
Copy link
Collaborator

@simpian is this still an issue, or can we close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants