Monitoring and handling errors in production
This guide describes how you can monitor and debug your functions in production.
How it works
Anchor 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. In other cases, the function can run successfully, but return unexpected results due to a bug in the function code.
To aid in debugging issues with a function, information about each function run is stored and made available through the Partner Dashboard. This includes metadata, such as when the run occurred and the shop that it was on, and function run details such as the function input and output.
Function run details are hidden by default for production shops because they can contain Personally Identifying Information (PII), unless they're shared by merchants. Merchants can share function run details by sharing an error report when the function fails or by sharing all function logs for an app.
Development shops are an exception and have all function run details visible.
Sharing function run details
Anchor link to section titled "Sharing function run details"When a merchant shares function run details from the Shopify admin, you can access them from the app's Extensions section in your Partner Dashboard.
Sharing an error report
Anchor link to section titled "Sharing an error report"When a function is executed and an error occurs, a warning notification is displayed on the relevant page in the Shopify admin. For example, if you've executed a discount function, then the warning notification appears on the Discounts page.
The warning notification 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 the Shopify admin, navigate to the page that's associated with the executed function.
- Click the warning notification.
- Click Share the error reports with
<developer-name>
. - Choose whether to include every time the customization ran within the last 24 hours.
- Click Share.
An email notification is sent to the Partner organization's specified business contact.
Share app function logs
Anchor link to section titled "Share app function logs"Merchants can share all function run details for an app within the past 24 hours, whether there were function failures or not.
- From the Shopify admin, navigate to the Apps and sales channels settings.
- Select the app that you need to share function run details for.
- Click the Share logs button in the Share function logs card.
- Click the Share logs button in the modal.
An email notification is sent to the Partner organization's specified business contact.
Debug a function
Anchor link to section titled "Debug a function"You can debug your function from the app's Extensions section in your Partner Dashboard.
- From your Partner Dashboard, go to Apps.
- Click the app that you deployed your function to.
- Click Extensions.
- Click the name of your function.
The function details page contains a list of function runs. After the merchant has consented to share function run details, you can inspect the details of each individual function run.
- 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 theSTDERR
logs of the function Error message: Contains the final message sent to
STDERR
before the function failed
List of errors
Anchor link to section titled "List of errors"The following table provides a complete list of errors that can occur when running your function:
Error name | Description |
---|---|
TimeoutError |
Shopify stopped the function after it ran for over 10 milliseconds (ms). |
RunError |
The function raised an exception. |
InstructionCountLimitExceededError |
Shopify stopped the function after it exceeded the maximum instruction count of 11 million instructions. |
StackMemoryLimitExceededError |
Shopify stopped the function after it exceeded the maximum stack size of 512kb. |
LinearMemoryLimitExceededError |
Shopify stopped the function after it exceeded the maximum linear memory size of 10mb. |
InvalidOutputError |
The function returned malformed or invalid output. This might occur because you printed debugging information to STDOUT , which is reserved for function output. If that's the case, then use STDERR instead. |
UnsupportedError |
The generated Wasm doesn't conform to Shopify Functions standards. |