Discussing Shopify Functions development, deployment, and usage in Shopify apps.
It says in docs:
`InstructionCountLimitExceededError: Shopify stopped the function after it exceeded the maximum instruction count of 11 million instructions.`
But it needs to be clarified what the actual cost 1 instruction is.
If I declare a variable does it cost 1 instruction? Or If there is 1 loop, does it cost 1 instruction?
This error is occurring in one store but users add less than 10 products to their cart
How is it possible to return this error?
Hi @temurbek --
An instruction is a WebAssembly instruction. You can't measure this by looking at your source code directly. However you can use Shopify CLI to execute your function locally and measure it. You can use standard language tools to measure and optimize the performance of your code.
There are cases with large orders that may be difficult to handle with Functions today. We have plans to address this. But 10 products should be manageable. Do you have a very large amount of data (e.g. metafields) being returned with each product? Or are you writing console logs on every loop through the cart potentially?
-Nick
Nick Wesselman | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Hello, Thank you for your response
Yes, I measured the instructions with Shopify CLI and it turns out that our Product Discount Function can handle approximately 150-180 line items
I think this amount is not bad, but our function is failing with one store even every hour
are there any other reasons for this error?
Thank you
Can you request the merchant share the error logs so that you can test your performance with those specific inputs?
Nick Wesselman | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog