Troubleshooting your Shopify function in production

Topic summary

Initial Workaround for Production Debugging:

A method was shared for troubleshooting Shopify functions in production by intentionally triggering panics/exceptions using a specific input (e.g., first name “Debug”). The approach involved:

  • Adding conditional code to cause a panic when triggered
  • Creating instructions for merchants to reproduce the error
  • Having merchants share the generated error report with developers

Code examples were provided for both Rust and JavaScript/TypeScript implementations.

Current Solution - No Longer Needed:

This workaround is now obsolete. Shopify has introduced a native feature allowing merchants to share 24 hours of execution logs for all functions directly from the Apps section in admin.

Key Benefits:

  • Eliminates need for “debug modes” or forced crashes
  • Provides direct access to function inputs and outputs
  • Simplifies troubleshooting process for both developers and merchants

Developers should use the official log-sharing functionality instead of implementing custom debugging triggers.

Summarized with AI on November 8. AI used: claude-sonnet-4-5-20250929.

Here are the steps to troubleshoot your Shopify function in production,

  1. Create a mechanism in your function to throw exception/cause panic based on a certain trigger, for example, if the first name is entered as “Debug”. This will ensure that this panic is not created in the function randomly when customers enter their details during checkout (Nobody has the first name of debug, right?).

This is how to do it in Rust (Place it near the end of the function, preferably),

if first_name == "Debug" {
    panic!("Debug mode activated");
}
  1. Create a mechanism for merchants to follow and generate and share the error logs with you. For example, you can show them a modal with steps to follow, the steps can look something like this,
  • Use the first name of Debug at the checkout to generate the error.

  • Go to the customization in the settings and click on share the error report with the developer.

  1. Once the merchant follows your instructions and successfully generates the error and shares with you, you will have all the details of what is going on at their checkout and what output did your function generate in response to the input it received.

Hope this helps.

2 Likes

Thanks for this @Sam9516 !

For JavaScript/TypeScript developers, you can do the same thing with something like

if (firstName == "Debug") {
  throw "Debug mode activated";
}
2 Likes

This sort of workflow shouldn’t be needed anymore! It’s now possible for merchants to share 24hr of execution logs for all functions in your app from the Apps section of admin. This should remove the need for “debug” modes and other hacks to force your function to crash, just to see the input and output.

https://shopify.dev/docs/apps/build/functions/monitoring-and-errors#share-app-function-logs

1 Like