Federation gateway crashing - no remote endpoint

Hi all,

I‘m trying to spin up a project using pm2 which is using federation and sadly I‘m stuck with the following error:

3|gateway | Polling running services is dangerous and not recommended in production. Polling should only be used against a registry. If you are polling running services, use with caution.
3|gateway | Error: Tried to load services from remote endpoints but none provided
3|gateway | at getServiceDefinitionsFromRemoteEndpoint
3|gateway | [nodemon] app crashed - waiting for file changes before starting…

I have tried to restart the gateway once all microservices are definitely up but to no avail.
I traced the issue back to the apollo server start call but I‘m lost on how to resolve this after having tried for days.
I‘m running this on a Macbook M1 and gateway runs on port 4000 (tried different ports, no solution).

Thanks for any help in the right direction.

Hi @cybort31 ,

3|gateway | Polling running services is dangerous and not recommended in production. Polling should only be used against a registry. If you are polling running services, use with caution.

One of the reasons the gateway emits this warning is because it needs the schemas in order to start up successfully. I suspect that pm2 is having all of your services start-up together and the ApolloGateway instance is falling over because the introspection requests are failing. This is a one of the reasons we talk about publishing schemas to a registry; GraphOS provides Launches for free with the Apollo Router.

One option that you have is providing the ApolloGateway instance a supergraphSdl instead of using the introspection (serviceList). You would use rover supergraph compose (docs) as a build step to create the supergraphSdl, then you could use pm2 to start everything at the same time because the ApolloGateway won’t need to make any requests to the downstream services to start up. The Launches feature I referenced above creates the supergraphSdl for you and the Apollo Router can be configured to hot reload with that Launch.

If you want to chat more about this, you can join our Discord Server and ping me (@watson). Hope to see you there!