Repository navigation
fix(cloud): a file upload waits at most 600 s for its answer once sent, instead of without end - #733
Merged
Merged
Conversation
…t, instead of without end POST /doc/, /classify/ and /split/ with a file were the only cloud requests with no timeout, so a connection that died after the file was sent left the call hanging. They now wait at most 600 s for the answer. Sending the file stays unlimited: requests sends the body in one write, so a connect timeout would cap the whole upload and fail a large file on a slow line.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…ach request's own timeout urllib3 before 1.26.15 sends a request on a pooled connection under the timeout its previous request left on the socket. An upload's (None, 600) then caps sending its file: at 30 s after a lookup such as list_collections(), at 600 s after another upload. With requests 2.31, a GET with timeout=0.5 then a 12 MB POST with (None, 600) on one session: ConnectionError after 0.5 s on 1.26.14, 200 after 2.2 s on 1.26.15. test_an_upload_takes_as_long_as_its_file_takes_to_send now cuts only the connect limit to 0.5 s and gives the read limit 10 s. The read timer starts once the last bytes reach the kernel, so a server still draining a large send buffer could pass 0.5 s on a busy runner.
This was referenced Dec 1, 2026
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.
A cloud file upload (
submit_document, Page Classify and Page Split with a PDF path) now waits at most 600 s for the server's answer once its file is sent, instead of waiting without end. Sending the file itself stays unlimited, as before.Why
Every cloud request the SDK sends has a timeout except the three that upload a file:
POST /doc/,POST /classify/andPOST /split/with a file.requestssets no timeout by default, so if the connection dies silently after the file is sent (a dropped NAT entry, a laptop that sleeps), the call never returns. #720 (Classify) and #716 (documents) found this.Both propose
timeout=(30, 600), which would break large uploads:requestsbuilds a multipart body as onebytesobject and urllib3 sends it in one write, so the first number caps sending the whole file, not each block. Measured on a loopback server reading about 6 MB/s, a 20 MB upload:(10, 600)(1, 600)(None, 1)With
(30, 600), a 50 MB scan on a 10 Mbit/s line (about 40 s) would fail at 30 s. That is why #389 left uploads without a timeout.What changes
UPLOAD_TIMEOUT = (None, 600)incloud_api.py, used by the three uploads: no limit while the file is sent, at most 600 s for the answer after it. The connect attempt keeps the operating system's own limit, as it has now.urllib3>=1.26.15(was>=1.26). Older releases send a request on a reused connection under the timeout its previous request left, so the send of an upload would be capped after all: at 30 s after a lookup such aslist_collections(), at 600 s after another upload. With requests 2.31, a GET withtimeout=0.5then a 12 MB upload with(None, 600)on one session: ConnectionError after 0.5 s on 1.26.14, 200 after 2.2 s on 1.26.15.Test plan
test_an_upload_the_server_does_not_answer_times_out_and_is_sent_once(document, classify, split): with the time limits cut to 0.3 s, a server that does not answer ends the upload withReadTimeoutafter one POST. Fails onmain(the upload waits for the answer).test_an_upload_takes_as_long_as_its_file_takes_to_send: a 12 MB upload to a server reading about 6 MB/s succeeds with the connect limit cut to 0.5 s (the read limit to 10 s). Fails with(30, 600)in place ofUPLOAD_TIMEOUT.test_cloud_request_wiringno longer asserts that an upload has no timeout.test_summary_effort_ladder_is_what_litellm_would_sendandtest_litellm_model_settings_list_matches_litellm_modelfail the same way onmainin this environment (its litellm version).