Skip to content

fix(web): keep the /graphql proxy when graphql starts after the indexer - #17

Merged
nimrod-teich merged 1 commit into
mainfrom
fix/mag-4953-graphql-proxy-late-upstream
Nov 5, 2026
Merged

nimrod-teich merged 1 commit into
mainfrom
fix/mag-4953-graphql-proxy-late-upstream

Conversation

@nimrod-teich

Copy link
Copy Markdown
Contributor

#Closes MAG-4953

Jira ticket: MAG-4953

Summary

  • Mux() resolved the GraphQL upstream once, at startup. If the name didn't resolve yet, it logged graphql.upstream rejected, skipping proxy and never registered /graphql. After a host reboot Docker starts every container at once, so the indexer can come up before its graphql container. It then answers 404 on /graphql until someone restarts it.
  • The private-network check now runs on every connection (privateDialContext):
    • the proxy is always registered;
    • an upstream that isn't running yet gets a 502 for that request;
    • the proxy works as soon as the upstream resolves.
  • The dialer connects to the vetted IP itself, so the DNS answer can't change between the check and the connect. The proxy also no longer goes through HTTP(S)_PROXY.
  • parseProxyUpstream still rejects bad schemes, a missing host and literal public IPs at startup. A hostname is no longer resolved there.

Test plan

  • go build ./... && go vet ./... && go test ./... all pass.
  • New internal/web/server_test.go:
    • TestParseProxyUpstream: an unresolvable hostname is accepted; ftp://, a missing host, 8.8.8.8 and 169.254.169.254 are rejected.
    • TestPrivateDialContextRefusesPublicAddresses: public and link-local addresses are refused at dial time.
    • TestGraphQLProxyRegisteredWhenUpstreamDoesNotResolve: /graphql answers 502, not 404.
    • TestGraphQLProxyRecoversWhenUpstreamStarts: 502 while the upstream is down, then 200 once it listens, with no restart.
  • Run against main's server.go, TestParseProxyUpstream and TestGraphQLProxyRegisteredWhenUpstreamDoesNotResolve fail. The second fails with /graphql status = 404, the exact symptom.

Mux() resolved the GraphQL upstream once at startup and skipped the
proxy if the name did not resolve yet. After a host reboot Docker starts
every container at once, so the indexer could come up before its
graphql container and serve 404 on /graphql until someone restarted it.

The private-address check now runs on every connection instead: the
proxy is always registered, a not-yet-running upstream gets a 502 for
that request, and the proxy works as soon as the upstream resolves. The
dialer connects to the vetted IP itself, so the DNS answer cannot change
between the check and the connect. A literal public IP is still refused
at startup.
@nimrod-teich nimrod-teich self-assigned this Nov 5, 2026
@nimrod-teich
nimrod-teich merged commit 731f06c into main Nov 5, 2026
1 check passed
@nimrod-teich
nimrod-teich deleted the fix/mag-4953-graphql-proxy-late-upstream branch November 5, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant