crystal icon indicating copy to clipboard operation
crystal copied to clipboard

Requests should time out if schema cannot be fetched in time

Open benjie opened this issue 3 years ago • 0 comments

Summary

If the initial schema takes a long time to build, or if it cannot build due to server issues (e.g. cannot connect to PostgreSQL and retryOnInitFail is on), requests to /graphql should not hang indefinitely.

Steps to reproduce

  1. Run postgraphile with retryOnInitFail
  2. Bring down PostgreSQL
  3. Make a request to /graphql

Expected results

Failure after a number of seconds (5? 10?) in GraphQL format notifying that a timeout occurred during schema construction.

Actual results

Requests hang indefinitely.

Possible Solution

Promise.race(getGraphQLSchema(), sleep(5000).then(() => Promise.reject(new Error("Timeout occurred waiting on GraphQL schema."))))

benjie avatar Mar 18 '21 11:03 benjie