Add startup timeout to prevent gateway hanging on unresponsive MCP servers #477
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Gateway would hang indefinitely during initialization if any backend MCP server failed to respond, blocking all other backends from starting.
Changes
Configuration: Added
startupTimeoutfield (default: 60s) to gateway config with package-level constants (DefaultStartupTimeout,DefaultToolTimeout,DefaultPort).Timeout enforcement: Implemented goroutine + buffered channel pattern in
GetOrLaunch()andGetOrLaunchForSession():Graceful degradation: Failed backends log warnings and gateway continues initialization with remaining backends.
Technical decisions
time.After()instead ofcontext.WithTimeoutto avoid canceling connection after successful startupWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
nonexistent.local/tmp/go-build3377049250/b269/launcher.test /tmp/go-build3377049250/b269/launcher.test -test.testlogfile=/tmp/go-build3377049250/b269/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true go user.email t[bot](dns block)/tmp/go-build481144272/b273/launcher.test /tmp/go-build481144272/b273/launcher.test -test.testlogfile=/tmp/go-build481144272/b273/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true dleware.test /tmp/go-build3677275879/b097/ ortcfg.link . --gdwarf2 --64 GL0vaMStIAuGbawbr5/sWo5QoaFO32xMT3YHtp6/k1XMsJiotFONAaFTgZJc(dns block)/tmp/go-build3502506537/b273/launcher.test /tmp/go-build3502506537/b273/launcher.test -test.testlogfile=/tmp/go-build3502506537/b273/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -lang=go1.25 docker-buildx x_amd64/vet se 7049250/b028/vetls-files x_amd64/cgo x_amd64/vet 791 6791 791 aw-mcpg/awmg se 7049250/b141/vet-c x_amd64/vet aw-mcpg/awmg(dns block)this-host-does-not-exist-12345.com/tmp/go-build3377049250/b278/mcp.test /tmp/go-build3377049250/b278/mcp.test -test.testlogfile=/tmp/go-build3377049250/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true g_.a --global rgo/bin/bash credential.helpe/opt/hostedtoolcache/go/1.25.6/x64/pkg/tool/linux_amd64/vet(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.