Can the instruction and input size limits be raised for large orders? #329
Replies: 27 comments 24 replies
-
Hello @thosakwe -- Thanks for the feedback and the detailed data! We have some plans around this which we hope to ship later this year. I will update this issue when it ships. |
Beta Was this translation helpful? Give feedback.
-
Moving to General Improvements since this applies to most/all existing Function APIs. |
Beta Was this translation helpful? Give feedback.
-
Thanks, Nick! Looking forward to the update. |
Beta Was this translation helpful? Give feedback.
-
Update: I recently ported my Function to Rust, and made big performance gains. Now, my function can handle 125 line items. So, my recommendation to anyone reading this is to stick with Rust for functions on public apps, so that you can meet as many merchants' needs as possible. |
Beta Was this translation helpful? Give feedback.
-
Is there any update on this? I would not consider this a possible improvement but actually feature breaking behavior that requires fixing. This behavior means that you can't trust the feature to work in a predictable manner. The input size might also vary in terms of other variables besides the raw number of line items. We will rewrite the function in question in Rust, but aren't too optimistic about the improvement as cart size seems to be the strongest determinant of instructions used. Is there any timeline for having this fixed or are there any updates in general? |
Beta Was this translation helpful? Give feedback.
-
Update: My Rust port turned out to be too large once compiled (it's 384KB), so it's not a solution to the problem. |
Beta Was this translation helpful? Give feedback.
-
Hi Nick, I'm working with Tobe. We've also noticed on exceptionally large errors, we also receive an We don't know how many line items it takes to trigger this at this time, as the input in the error report was truncated. Tobe will follow up with more details about the Thanks! |
Beta Was this translation helpful? Give feedback.
-
Is there any update to this? We support a few Shopify Plus accounts (that pay quite a lot per month honestly) and we sold them the idea that Shopify can scale but when we have to go back and point to limitations like these, we look like a bunch of amateurs or that we basically lie about it, when they were able to handle stuff like this on Woocommerce just fine. |
Beta Was this translation helpful? Give feedback.
-
Also looking for an update and solution to this issue as well. We are working with the cart transform function using Typescript. |
Beta Was this translation helpful? Give feedback.
-
Are there any updates regarding this? Unfortunately, it doesn't seem that anything related to this crucial limitation is included in the roadmap: https://shopify.dev/docs/apps/checkout#shopify-functions This is still breaking lots of intended use cases. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi there, Hi @nickwesselman Are there any plans to raise the maximum instruction count from 11 million instructions limit? |
Beta Was this translation helpful? Give feedback.
-
For our use case, we have a custom app that allows our users to create bundle discounts and free gifts like the good old days with Scripts. Using Scripts we could have up to around 80 bundles of various combinations within the script size limit. With a function we are restricted to around 20, both because of the instruction count limit and the metafield input size limit. The workaround for us involved splitting our active discount configurations across 5 Discount Nodes, giving us 5x the amount of instructions. What this meant for us:
And then there was another big problem - having to find a way of adding some extra discount logic after the previous discounts had been applied. There is no real way to set the order of execution for functions, so if you want to apply a discount after some other discounts have been calculated you can put it in the same function right? But what if you have 5 discount function executions and you only want this extra discount logic running on the 5th function execution? I found that upon creating the 5 Discount Nodes, the last to be created would consistently run last. So that's what we've had to do to make it work. So far so good but hopefully it doesn't change because our system will break. Attempt at your own risk lol. Now we can run roughly the same number of discounts using functions as we did with Scripts. It has been an incredibly arduous journey for us to reach this point and we only wish we'd known about the Scripts deprecation date extension before embarking on this rollercoaster. Hope that's useful! |
Beta Was this translation helpful? Give feedback.
-
Hi guys, just stumbled across this limitation and it looks like it's completely breaking our B2B pricing use-case. Does anyone know when the improvements will be rolled out? We are handling prices using the shopify Metafield and Cart Transformer API. Unfortunately when the function bugs out, we get the incorrect price in the cart. |
Beta Was this translation helpful? Give feedback.
-
Over the past 10 months, it’s become clear that the 11M instruction count limit affects not just large orders but also functions that pull a lot of data. Take a discount function as an example: if it checks if a product is in several collections, the input size increases along with the line items. Because of the required JSON parsing, you're likely to hit the instruction limit quickly, even if there aren't many items in the cart. Instead of linking the limit to the number of line items, it might be better to base it on the size of the input. This way, the limits can stay tight (to avoid overloading the server) but won’t be too restrictive. If Shopify Functions are going to take over from scripts, adjusting how they scale could make this transition smoother. EDIT: Another possible option is to increase the number of Functions a store can create (for example, more than 5 discount functions, or more cart transforms), you can still have strict limits on the instruction count, but merchants will be able to create more Functions to cover all their bases. |
Beta Was this translation helpful? Give feedback.
-
Any update on this for JavaScript functions? We are about to bring wholesalers on line and this is preventing that. But it's not just wholesalers. We are stuck at around 33 items in the cart right now. On sale days, that's nothing. I am looking at the previous comments and seeing lots of promises about "later this year" in 2023 and "changes planned for q1"... We're in Q3 now and no fix in sight. Please update... |
Beta Was this translation helpful? Give feedback.
-
Looks like I've got to move to Rust |
Beta Was this translation helpful? Give feedback.
-
Also stuck. Migrating to Rust tonight apparently :( |
Beta Was this translation helpful? Give feedback.
-
Bumping this aswell, the cap should really be increased or at the very least be based on the number of items in the cart. |
Beta Was this translation helpful? Give feedback.
-
For those who is moving to Rust, it's not yet the optimal result, I am using Rust and JS extensions.. the performance of Rust is better and allows more flexibility, but when cart items grows it often (1% rate error) generates these 2 types of errors: |
Beta Was this translation helpful? Give feedback.
-
@nickwesselman hey, are you going to share any more updates on this issue, except updates from Shopify CLI 3.67.0? |
Beta Was this translation helpful? Give feedback.
-
Been seeing a lot more RuntimeError errors ever since upgrading to CLI 3.67.0 and @shopify/shopify_function 1.0.0, whereas before it was strictly just InputSizeLimitExceededError & InstructionCountLimitExceededError. For my product discount function at least I know I haven't changed anything but the dependency version. The functions are still running well for the most part but is there any way I can get more insight into these errors without having to reach out to the merchant to ask them to share? |
Beta Was this translation helpful? Give feedback.
-
This is impacting a lot of our largest merchants. Agreed with the above, it's hard to square what we tell merchants about how amazing Shopify is with 'well, those customizations won't work when your best customers have too many socks in the cart' 😅 |
Beta Was this translation helpful? Give feedback.
-
Thank you for the recent update to resource limits (changelog link). While it’s a positive step, I’m curious why 200 cart lines were chosen as the threshold, as most orders that encounter this issue have significantly fewer line items. Many developers in the community, as reflected in this discussion, have highlighted similar concerns. I’d like to ask that this not be the final improvement. This issue affects merchants and developers alike and has caused significant challenges, including lost customers. Further adjustments, such as scaling based on input size rather than just cart lines, would make Shopify Functions a much more viable replacement for scripts. Thank you for your consideration. |
Beta Was this translation helpful? Give feedback.
-
With BFCM fast approaching, I'm sure many of us are looking for ways to improve performance of Functions. Here are some tips that helped me drastically reduce the number of instructions my app's functions use:
I hope this is helpful to someone. |
Beta Was this translation helpful? Give feedback.
-
In case it helps anyone else here, it appears as if the function extensions now also have a new way to access JSON data stored in metafields. You can directly access the JSON stored data as a JSON object, rather than as a raw string: https://shopify.dev/changelog/new-metafield-jsonvalue-field It was first released as part of We still need to test this for our use cases, but the write up here seems promising:
|
Beta Was this translation helpful? Give feedback.
-
Hi! Thank you everyone for sharing your experience. In our case, we have a lot of additional information that is necessary to bundle the items and fulfill the order, and we add it to line-item properties and order attributes, which also makes our output to big for functions. |
Beta Was this translation helpful? Give feedback.
-
Currently, Shopify Functions can execute 11 million instructions max before failing with a
RunOutOfFuel
error.What's the problem?
This poses a problem for large orders. When there are many cart lines in the input, JSON parsing alone can eat up a significant portion of that quota.
For example, many stores sell wholesale, where there are sometimes 80+ line items in the cart. In cases like this, the input JSON size can easily exceed 9KB. When you have 100 line items? 11KB and beyond.
I ran a script that runs my function with increasing number of cart lines, and stops when it hits 11M instructions. Here's a screenshot of the results (caps out at 34 cart lines):
To be fair, the specific function I was running here was in TypeScript, so I knew it wouldn't be super-efficient. However, I also wrote a barebones function in C++, using RapidJSON (the fastest C++ JSON library), and that capped at 69 cart lines.
It doesn't really even matter which parser you use, because even the fastest JSON parsers, such as LL(1) parsers, are O(n) in the worst case. And that's before the actual discount logic runs.
Why is this important?
There's no way to work around this, because discount functions have to query
input.cart.lines
in order to get product variant IDs to return inFunctionResult.targets
.As is, discount functions will always fail for large orders, so they're not usable for certain groups of merchants.
Potential solution
It would be amazing if the instruction limit were proportional to the number of cart lines, instead of having a one-size-fits-all limit.
Thank you for your consideration.
Beta Was this translation helpful? Give feedback.
All reactions