Deduplicate MCP_GATEWAY_SESSION_TIMEOUT env-var lookup into shared getSessionTimeout()#5100
Merged
Merged
Conversation
5 tasks
…tSessionTimeout() Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/91eba52b-1b44-40e0-a96a-61fcd204b6be Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix duplicate env-var literal for session timeout
Deduplicate MCP_GATEWAY_SESSION_TIMEOUT env-var lookup into shared getSessionTimeout()
May 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes duplication of the MCP_GATEWAY_SESSION_TIMEOUT env-var lookup by consolidating it into a single package-level helper (getSessionTimeout()), so both routed and unified (transport) server creation paths share the same default and env wiring.
Changes:
- Renamed
getRoutedSessionTimeout()togetSessionTimeout()and updated its comment to reflect shared usage. - Updated unified transport server creation to use
getSessionTimeout()instead of inliningenvutil.GetEnvDuration(..., 6*time.Hour), allowing removal of now-unused imports. - Updated routed-mode tests to call the renamed helper.
Show a summary per file
| File | Description |
|---|---|
| internal/server/transport.go | Switches unified-mode StreamableHTTP SessionTimeout to shared getSessionTimeout() and removes unused imports. |
| internal/server/routed.go | Renames and repurposes the session timeout helper as the shared implementation for both modes. |
| internal/server/routed_test.go | Updates tests to call getSessionTimeout() after the rename. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
envutil.GetEnvDuration("MCP_GATEWAY_SESSION_TIMEOUT", 6*time.Hour)was inlined intransport.godespiterouted.goalready owning an identical wrapper — two places to update if the env-var key or default ever changes.Changes
routed.go— RenamegetRoutedSessionTimeout()→getSessionTimeout(); update its doc comment to reflect shared ownershiptransport.go— Replace inline literal withgetSessionTimeout(); drop now-unusedenvutilandtimeimportsrouted_test.go— UpdateTestRoutedModeSessionTimeout_ReadsEnvVarcall sites to the new name; test coverage is unchangedWarning
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:
example.com/tmp/go-build602771692/b513/launcher.test /tmp/go-build602771692/b513/launcher.test -test.testlogfile=/tmp/go-build602771692/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build602771692/b428/vet.cfg ache/go/1.25.9/x64/src/runtime/cgo /tmp/go-build3583632305/b314/ x_amd64/vet . --gdwarf2 --64 x_amd64/vet go_.�� 64/src/net -I x_amd64/vet --gdwarf-5 ions =0 x_amd64/vet(dns block)invalid-host-that-does-not-exist-12345.com/tmp/go-build602771692/b495/config.test /tmp/go-build602771692/b495/config.test -test.testlogfile=/tmp/go-build602771692/b495/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build602771692/b365/vet.cfg Ua_e/htfOW-jx_xLgo1.25.9 ache/go/1.25.9/x-c=4 x_amd64/vet 0276810/b172/ go.opentelemetry-atomic(dns block)nonexistent.local/tmp/go-build602771692/b513/launcher.test /tmp/go-build602771692/b513/launcher.test -test.testlogfile=/tmp/go-build602771692/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build602771692/b428/vet.cfg ache/go/1.25.9/x64/src/runtime/cgo /tmp/go-build3583632305/b314/ x_amd64/vet . --gdwarf2 --64 x_amd64/vet go_.�� 64/src/net -I x_amd64/vet --gdwarf-5 ions =0 x_amd64/vet(dns block)slow.example.com/tmp/go-build602771692/b513/launcher.test /tmp/go-build602771692/b513/launcher.test -test.testlogfile=/tmp/go-build602771692/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build602771692/b428/vet.cfg ache/go/1.25.9/x64/src/runtime/cgo /tmp/go-build3583632305/b314/ x_amd64/vet . --gdwarf2 --64 x_amd64/vet go_.�� 64/src/net -I x_amd64/vet --gdwarf-5 ions =0 x_amd64/vet(dns block)this-host-does-not-exist-12345.com/tmp/go-build602771692/b522/mcp.test /tmp/go-build602771692/b522/mcp.test -test.testlogfile=/tmp/go-build602771692/b522/testlog.txt -test.paniconexit0 -test.timeout=10m0s(dns block)If you need me to access, download, or install something from one of these locations, you can either: