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?
