401 Error in production App.

Good morning everyone, I’ve been facing an issue with my Shopify app in production due to two errors that occur only in production.

1: It’s a 500 error that happens only during the app installation. It occurs because my store can’t be validated on the first load, which returns an “Application Error.” I’ve had this error before and managed to fix it, but it’s not consistent and that makes it difficult to solve.

2: It’s a 401 error that happens very frequently and is ruining the user experience. At first, I was getting this error only in the dev environment, and after reading the README I saw the issue about the “nbf” claim timestamp check failed. I adjusted this locally and it worked, but in production this error keeps happening. Logging the timestamps in GCP, I verified that the server timestamp is correct, but Shopify’s timestamp comes 2 minutes ahead, or sometimes comes as null.

2025-11-17 08:49:11.118 BRT
Auth attempt - Time check: { serverTimestamp: 1763380151, requestTimestamp: null }
2025-11-17 08:49:11.118 BRT
Auth attempt - Time check: { serverTimestamp: 1763380151, requestTimestamp: null }

2025-11-17 08:49:03.295 BRT
Auth attempt - Time check: { serverTimestamp: 1763380143, requestTimestamp: '1763380142' }
2025-11-17 08:49:03.295 BRT
Auth attempt - Time check: { serverTimestamp: 1763380143, requestTimestamp: '1763380142' }

Hi @Naper_AI

For error 1, this is likely related to:

  • Database connection timing during first load
  • Store data not being available when validation runs
  • Race condition between store installation and first request

For 2, based on your logs, you have two scenarios:

  • Null timestamps: requestTimestamp: null - This happens when the JWT is missing or the nbf claim is not present
  • Time skew: requestTimestamp: ‘1763380142’ vs serverTimestamp: 1763380143 - Actually looks correct here (1 second difference)