crystal
crystal copied to clipboard
Requests should time out if schema cannot be fetched in time
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
- Run postgraphile with
retryOnInitFail
- Bring down PostgreSQL
- 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."))))