fix(server): add timeout to all requests.get() calls to prevent indefinite hangs (#64)#86
Open
TumCucTom wants to merge 1 commit into
Open
fix(server): add timeout to all requests.get() calls to prevent indefinite hangs (#64)#86TumCucTom wants to merge 1 commit into
TumCucTom wants to merge 1 commit into
Conversation
…inite hangs The 6 requests.get() call sites in minimax_mcp/server.py had no timeout= argument, so a slow or unresponsive remote server would block the MCP tool pipeline indefinitely with no way to recover short of killing the process. Add a module-level DOWNLOAD_TIMEOUT = 120 in const.py and pass it to every requests.get() call. For video downloads (generate_video, query_video_generation) also add stream=True to avoid loading the whole file into memory before writing it out. MinimaxTimeoutError (already defined in exceptions.py) is a subclass of MinimaxRequestError, which is already caught by the existing except blocks — no exception-routing change needed. Fixes MiniMax-AI#64. Co-authored-by: Zippy AI <tomkinsbale@icloud.com> Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.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.
Summary
DOWNLOAD_TIMEOUT = 120constant inminimax_mcp/const.py.timeout=DOWNLOAD_TIMEOUTto all 6requests.get()call sites inminimax_mcp/server.py.generate_video,query_video_generation) also addstream=Trueto avoid loading whole file into memory.tests/test_download_timeout.pyverifies the timeout is plumbed through.Why
Issue #64: missing timeouts meant a slow remote could block the MCP server forever.
requests.Timeoutis a subclass ofrequests.RequestExceptionwhich is already caught by existing except blocks, so no new exception handling is needed.Test plan
tests/test_download_timeout.pymocksrequests.getand asserts the timeout kwargpytest tests/greenFixes #64.
🤖 Generated with Claude Code