Shopify Functions error handling
This guide describes the reasons that functions fail, how you can debug production failures, and a complete list of errors that can occur when running functions.
How it worksAnchor link to section titled "How it works"
Functions can fail by raising an exception, exceeding memory or time limits, or returning data that doesn't match the schema of the specific Function API.
Monitoring lifecycleAnchor link to section titled "Monitoring lifecycle"
The following diagram shows the activities that happen when monitoring functions:
- App users receive error notifications and share error reports with developers.
- App developers monitor functions in their Partner Dashboard.
Error reportsAnchor link to section titled "Error reports"
When a function is executed and an error occurs, a banner displays in the customization page of the Shopify admin. The banner contains information about when errors started occurring. It also includes a link that enables app users to share information with developers about failed function runs.
After an app user has shared an error report, the developer receives an email notification.
If you're working in a development store, then failed and successful function runs are visible by default. You don't need to share the error report for the runs to display in the Partner Dashboard. Success runs are visible only for development stores.
Sharing error reportsAnchor link to section titled "Sharing error reports"
When the user shares an error report from the Shopify admin, you can access it from the app's Extensions section in your Partner Dashboard.
Share a test error reportAnchor link to section titled "Share a test error report"
When a function is executed and an error occurs, a banner displays on the relevant page in the Shopify admin. For example, if you've executed a discount function, then the banner displays on the Discounts page.
The banner contains information about when errors started occurring. It also includes a link that enables users to share information with developers about function runs that failed.
- From your Shopify admin, navigate to the page associated with your executed function.
- Click the error banner.
- Click Share the error reports with
- Select whether the error report includes the last ten times the customization ran on checkout.
- Click Share.
You'll receive an email notification.
Access the error reportAnchor link to section titled "Access the error report"
- From your Partner Dashboard, go to Apps.
- Click the app that you deployed your function to.
- Click Extensions.
- Click the name of your function.
In the Total errors box, click Error runs.
All of the function runs that failed display in a list.
From the list, click the failed function run that you shared.
You can view the error report.
You can debug errors from the app's Extensions section in your Partner Dashboard. After the app user has consented to send the execution logs, you can inspect the details of each individual error.
- Input (
STDIN): The JSON formatted input that you can copy to your clipboard. For illustrative purposes, the input in the screenshot has been omitted.
- Output (
STDOUT): Contains the output, if the function returned output
- Logs (
STDERR): Contains the
STDERRlogs of the function
Error message: Contains the final message sent to
STDERRbefore the function failed
List of errorsAnchor link to section titled "List of errors"
The following table provides a complete list of errors that can occur when running your function:
||Shopify stopped the function after it ran for over 5 miliseconds (ms).|
||The function raised an exception.|
||Shopify stopped the function after it exceeded the maximum stack size of 512kb.|
||Shopify stopped the function after it exceeded the maximum linear memory size of 10mb.|
||The function returned malformed or invalid output. This might occur because you printed debugging information to
||The generated Wasm doesn't conform to Shopify Functions standards.|