--- title: Monitoring and handling errors in production description: Learn how you can monitor and debug functions when errors occur in production. source_url: html: 'https://shopify.dev/docs/apps/build/functions/monitoring-and-errors' md: 'https://shopify.dev/docs/apps/build/functions/monitoring-and-errors.md' --- # Monitoring and handling errors in production **Functions availability:** * Stores on any plan can use public apps that are distributed through the Shopify App Store and contain functions. Only stores on a [Shopify Plus plan](https://help.shopify.com/manual/intro-to-shopify/pricing-plans/plans-features/shopify-plus-plan) can use [custom apps](https://help.shopify.com/manual/apps/app-types/custom-apps) that contain [Shopify Function APIs](https://shopify.dev/docs/api/functions). * Some Shopify Functions capabilities are available only to stores on a [Shopify Plus plan](https://help.shopify.com/manual/intro-to-shopify/pricing-plans/plans-features/shopify-plus-plan). See [Shopify Function APIs](https://shopify.dev/docs/api/functions#availability-of-shopify-functions) for details. This guide describes how you can monitor and debug your functions in production. *** ## 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](https://shopify.dev/docs/api/functions). 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 [Dev Dashboard](https://dev.shopify.com/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. *** ## Access function run details The visibility of these details is controlled by the access scopes a merchant has granted to your app. Shopify derives the scopes required to view a run from the fields your function's [input query](https://shopify.dev/docs/api/functions/current#input) reads. If your app has the right scopes, then you can see the run details. If run details are hidden, your app is missing required scopes. Choose the request method that fits your use case: * **Request scopes during app installation**: Use this for scopes your app consistently needs. For instructions on declaring and requesting scopes, refer to [Access scopes](https://shopify.dev/docs/api/usage/access-scopes). * **Request protected customer data scopes when accessing customer data**: Some fields, like customer details and addresses, require protected customer data access. For the approval process and data-level scopes, refer to [Protected customer data](https://shopify.dev/docs/apps/launch/protected-customer-data). * **Use optional scopes for occasional or debugging access**: If you need a scope only occasionally, such as for debugging, request it as an [optional scope](https://shopify.dev/docs/apps/build/authentication-authorization/app-installation/manage-access-scopes#request-new-access-scopes-dynamically). Merchants can grant or revoke optional scopes without reinstalling your app. After the required scopes are granted, run details are visible the next time you view the log. **Note:** If you have access to the store as a staff member or collaborator, then you can see all run details regardless of your app's access scopes. This means run details on your organization's dev stores are always accessible to you. *** ## Debug a function You can debug your function from the app's **Logs** section in your [Dev Dashboard](https://dev.shopify.com/dashboard/). 1. From your Dev Dashboard, go to **Apps**. 2. Click the app that you deployed your function to. 3. Click **Logs**. 4. Click **Functions**. The function details page contains a list of function runs. When your app has the required access scopes, you can inspect the details of each individual run. **Note:** Functions are deterministic, which means that any time they execute with a given input, they always return the same output. You can therefore copy the input in a function run and accurately reproduce the failing execution locally using [Shopify CLI](https://shopify.dev/docs/apps/build/functions/test-debug-functions#execute-the-function-locally-using-shopify-cli) or a [unit test](https://shopify.dev/docs/apps/build/functions/test-debug-functions#writing-unit-tests-for-functions). ![A screenshot of a function error report in the Dev Dashboard](https://shopify.dev/assets/assets/images/api/functions/run-error-DQM8kom5.png) 1. **Input (STDIN)**: The JSON formatted input that you can copy to your clipboard. 2. **Output (STDOUT)**: Contains the output, if the function returned output 3. **Logs (STDERR)**: Contains the logs of the function **Caution:** Function logs are truncated after 1 kB. *** ## List of errors The following table provides a complete list of errors that can occur when running your function: | Error name | Description | | - | - | | `RuntimeError` | The function raised an exception or exited with a non-zero status code during execution. | | `InstructionCountLimitExceededError` | Shopify stopped the function after it exceeded the maximum [instruction count](https://shopify.dev/docs/api/functions/current#dynamic-limits). | | `StackMemoryLimitExceededError` | Shopify stopped the function after it exceeded the maximum [stack memory size](https://shopify.dev/docs/api/functions/current#fixed-limits). | | `LinearMemoryLimitExceededError` | Shopify stopped the function after it exceeded the maximum [linear memory size](https://shopify.dev/docs/api/functions/current#fixed-limits). | | `InvalidOutputError` | The function returned malformed or invalid output. | | `OutputTooLargeError` | The function's output exceeded the maximum allowed [output size](https://shopify.dev/docs/api/functions/current#dynamic-limits). | | `InputSizeLimitExceededError` | The function's input exceeded the maximum allowed [input size](https://shopify.dev/docs/api/functions/current#dynamic-limits). | | `InputListSizeLimitExceededError` | A variable array in the function's input query exceeded the maximum allowed list length. For more information, refer to [input query limits](https://shopify.dev/docs/api/functions/current#input-query-limits) and [using variables in input queries](https://shopify.dev/docs/apps/build/functions/input-queries/use-variables-input-queries). | | `InvalidModuleError` | The Wasm module failed validation at deployment. | | `InvalidInputQueryError` | The function's input query is invalid for its API version. | | `UnsupportedVersionError` | The function is using an unsupported API version. It has been removed from all merchant stores. To fix this, upgrade to a later API version and redeploy your app. | | `InvalidVariableValueError` | The function's input query variables metafield was invalid. This can occur if the metafield value doesn't conform to the variables definitions, or if the metafield type isn't `json`. For more information, refer to [using variables in input queries](https://shopify.dev/docs/apps/build/functions/input-queries/use-variables-input-queries). | ***