Unrealistic 250-Item Carts Causing Function Failures

Hey Guys!

We’re noticing "InstructionCountLimitExceededError" logs appearing in our function run logs. While the volume of these errors is good enough to take a note of, we’ve not received any complaints from merchants about their discounts failing.

After investigating, we observed a pattern:
→ Some store logs consistently show 250 cart line items.
→ This is highly unrealistic for 99% of our customers, which explains why merchants haven’t reached out to us.
→ Analyzing their order data reveals that the maximum number of line items per order is typically between 70-80, and at most, 110.
→ What’s puzzling is how these carts with 250 line items are being generated in the first place. Merchants seem unaware of any automation scripts or testing setups that might be creating such carts without placing corresponding orders.

This makes it challenging to distinguish realistic errors from these anomalies (if any). Additionally, it’s unclear why multiple stores are experiencing failures with the same cart line item count of 250. Reducing our error rate is crucial to ensure our functions are properly optimised but if we get these errors it’s becoming very difficult to understand.

While we continuously optimise our functions with every upgrade, handling 250 items per cart is currently not possible right now. If this issue had been flagged by merchants and if they had been creating these carts, we could prioritise a solution. However, given their lack of awareness, we’re struggling to determine the root cause.

PS: The number stores with these logs is not that high right now, but we’re very curious to understand what’s causing this.
If anyone has insights into this or has encountered a similar issue, your input would be greatly appreciated.
Thanks a lot!

1 Like

The error is logged when shopify stopped the function after it exceeded the maximum instruction count of 11 million instructions.

For handling large data payloads, consider using Rust, as it may help avoid exceeding Shopify’s instruction limit, potentially preventing an InstructionCountLimitExceededError.

1 Like

I think Shopify also has plans to let the limit scale based on the size of the cart Can the instruction and input size limits be raised for large orders? · Shopify/function-examples · Discussion #329 · GitHub

In the meantime, one thing that I did to get an easy win was to bump my Shopify CLI version above 3.68.1 which had some optimizations around instruction size, this will at least reduce the errors but not eliminate them until they update the functions to scale based on cart size.

1 Like

I have the same concern but more about the InputSizeLimitExceededError. Bots submit large cart with 250 line items but I don’t have any way to deal with them

Migrating to Rust can reduce the instruction counts. But this cannot help to fix the input size error.

1 Like

Came here to post about a similar thing.

We’re getting a huge amount of these errors based on what looks like bot activity as there are always 200+ line items, which isn’t typical for our merchants.

Is Shopify doing something to either prevent these bots from adding to cart, or to better message these outlier cart errors to merchants?

1 Like

I have the same question about this topic.