app-bridge dispatch rate limited?

mngibso
Tourist
4 0 0

I'm using app-bridge to to add multiple items and discounts to a cart in a short period of time.
e.g.

addLineItemToCart(data: AddLineItemData): void => {
  this.cart.dispatch(Cart.Action.ADD_LINE_ITEM, { data });
}
items.map((i) => addLineItemsToCart(i));


Later, I fetch the cart to confirm items have been added.

I find that sometimes, especially when adding many items, some items don't get added or discounts don't get applied.

This leads me suspect I'm running into rate-limiting. Is there any way to confirm this suspicion in app-bridge? 

Replies 3 (3)

JoeyF
Shopify Staff (Retired)
35 7 12

@mngibso , thanks for reporting this.

There is no explicit rate-limit in App-Bridge, so what you're describing seems like a bug.

 

I will ask the team to look into it. In the meantime, if you can answer these questions, it might help us to try and reproduce the issue:

 

  • Was this always the case, or did it start recently?
  • Which version of App-Bridge and POS are you using?
  • You mentioned that this issue usually happens when you add many items. In this context, how many is "many items"?
  • Just as an experiment, if you add a short delay between the `addLineItemsToCart` calls, does it fix the problem?

To learn more visit the Shopify Help Center or the Community Blog.

mngibso
Tourist
4 0 0

Thanks for the prompt response!


To give you more information, the app will add line items, then immediately update those line items with a discount via `SET_LINE_ITEM_DISCOUNT`. It's the discount call I see isn't getting applied to the cart more than the `ADD_LINE_ITEM`.

 

  • Was this always the case, or did it start recently?
    • I originally saw this when I was developing the app. I added a 50 ms delay between calls and that seemed to mitigate the problem for the most part. I would occasionally see an error but it was uncommon enough to be considered non-critical.
    • Recently, I've been seeing this problem occur much more often - 1 or 2 orders a day.
  • Which version of App-Bridge and POS are you using?
    • I originally saw the bug under 2.1.0, but upgraded to 3.1.1 and was still seeing the error
  • You mentioned that this issue usually happens when you add many items. In this context, how many is "many items"?
    • more than 25 line items added, and a discount then applied to each.
  • Just as an experiment, if you add a short delay between the `addLineItemsToCart` calls, does it fix the problem?
    • I've changed the delay from 50 ms to 200 ms. This seems to have fixed the problem.
JoeyF
Shopify Staff (Retired)
35 7 12

@mngibso , I confirmed with our engineering team that there is a race condition in the POS app.

The team is working on a fix, and I hope they'll be able to get it ready in time for the next POS release. I'll follow up as soon as I know that the fix has been released.

To learn more visit the Shopify Help Center or the Community Blog.