Node.js using @shopify/shopify-app-express crashes on 50x API responses

Topic summary

Node.js app using the @shopify/shopify-app-express library crashes whenever Shopify’s API returns a 5xx server error (500, 502, 503, 504), rather than allowing errors to be handled.

  • Context: A custom Express auth middleware calls shopify.validateAuthenticatedSession()(req, res, next). A surrounding try/catch does not intercept errors, suggesting the middleware’s async behavior bypasses the catch and causes an unhandled exception.
  • Impact: Users see a white screen and the app fails to load, indicating poor UX and a lack of recoverable error handling on 5xx responses. Occurrence is random and tied to Shopify API responses.
  • Technical note: validateAuthenticatedSession is an Express middleware for authenticated session validation; 5xx are server errors from Shopify’s API.
  • Latest update: A community member recommended reporting the issue to the official repository’s issue tracker (shopify-app-js).

Status: No workaround or fix was provided; the issue remains open pending investigation on GitHub.

Summarized with AI on January 19. AI used: gpt-5.

Hi, community.

Faced a very strange issue using Node.js as the app backend with @shopify/shopify-app-express library.

We have an auth middleware that utilizes shopify.validateAuthenticatedSession():

// middleware

const customAuthMiddleware = async (req, res, next) => {
  try {
    shopify.validateAuthenticatedSession()(req, res, next);
  } catch (e) {
    console.log(e);
  }
};

app.use('/api/listing', customAuthMiddleware, MainRoutes);

And when we get an API response from Shopify with code > 500, the try…catch block doesn’t work, and the app crashes. It happens randomly and depends only on Shopify API response. If the response is successful - everything is OK, but if not - it crashes (with different codes, 500, 502, 503 or 504).

And the weird thing is that we can’t catch and process errors. It seems some async function inside the library prevents the error from being caught. So, the user sees just a white screen, and the app fails to load—very bad UX.

Does anybody know how to fix such behavior?

Hey @vitaly_radchik

Please post this issue here: https://github.com/Shopify/shopify-app-js/issues

1 Like