GraphQL Error (Code: 504) 504 Gateway Time-out

I’m sometimes getting this error in Chrome’s dev console.

Error: GraphQL Error (Code: 504): {
  "response": {
    "error":"<html>\r\n<head><title>504 Gateway Time-out</title></head>\r\n<body>\r\n<center><h1>504 Gateway Time-out</h1></center>\r\n<hr><center>nginx/1.18.0 (Ubuntu)</center>\r\n</body>\r\n</html>\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n",
    "status":504,
    "headers":{
      "map":{
        "content-length":"578",
        "content-type":"text/html",
        "date":"Sun, 13 Feb 2022 23:48:59 GMT",
        "server":"nginx/1.18.0 (Ubuntu)"
      }
    }
  },
  "request":{
    "query":"query CarInfoQuery($licenseNbr: String!) {\n  carInfo: getCarInfo(licenseNbr: $licenseNbr) {\n    abrNo\n    year\n    brandModel\n    vin\n  }\n}",
    "variables":{
      "licenseNbr":"MHT534"
    }
  }
}

Looking at my server logs it looks like the request came in at 00:48:54 and finished 00:49:00 also see this in my logs: api | 00:49:00 🌲 request completed 5.8s

What is it exactly that times out? And how can I increase the time-out?

Since you are serverful, the api server times out here (in Fastify) which can be configured, see: Docs - App Configuration: redwood.toml : RedwoodJS Docs

/**
 * This file allows you to configure the Fastify Server settings
 * used by the RedwoodJS dev server.
 *
 * It also applies when running the api server with `yarn rw serve`.
 *
 * For the Fastify server options that you can set, see:
 * https://www.fastify.io/docs/latest/Reference/Server/#factory
 *
 * Examples include: logger settings, timeouts, maximum payload limits, and more.
 *
 * Note: This configuration does not apply in a serverless deploy.
 */

/** @type {import('fastify').FastifyServerOptions} */
const config = {
  requestTimeout: 15_000,
  logger: {
    level: process.env.NODE_ENV === 'development' ? 'debug' : 'warn',
  },
}

See the docs above for a link to all the possible config settings from Fastify.

Thanks DT. I saw that docs page, but didn’t think that was it. I got my timeout in ~5 sec, but that page says default is 15 seconds. But maybe I shouldn’t be looking at requestTimeout?

Maybe it is a Prisma timeout?

You can configure that on your connection string — both for connection and a pool:

1 Like

That could be it! I’ll try to tweak that when/if it happens again. It’s been behaving nice lately…