Fix ProtocolError exceptions bypassing download resume logic#14084
Fix ProtocolError exceptions bypassing download resume logic#14084lets-build-an-ocean wants to merge 5 commits into
ProtocolError exceptions bypassing download resume logic#14084Conversation
|
Hi @lets-build-an-ocean, thank you for your contribution! |
Thanks for the quick review and for confirming the fix works! No rush at all — I really appreciate the time you and the other volunteers put into this project. |
notatallshaw
left a comment
There was a problem hiding this comment.
Hope you don't mind, but I've added some more extensive unit tests. Otherwise looks good.
Thank you for the additional tests and the approval. Much appreciated! |
When a download is interrupted mid-stream by a sudden network drop, urllib3 raises a
ProtocolError(wrapping anIncompleteRead). Because_process_response()only caughtReadTimeoutError, theProtocolErrorpropagated uncaught, skipping theis_incomplete()check in__call__()and never reaching_attempt_resumes_or_redownloads(). This means pip's built-in resume logic was never triggered.Fixes #14079
What I changed:
ProtocolErrorto theexceptclause in_process_response()so broken connections are handled the same as timeouts.ProtocolErrorto the retry loop'sexceptclause in_attempt_resumes_or_redownloads()so resume attempts that also drop don't crash either."Connection interrupted while downloading."since it now covers both timeouts and broken connections.Testing:
Added a unit test that simulates a
ProtocolErrorbeing raised mid-stream and verifies pip resumes and completes the download instead of crashing. Also verified manually using the reproduction script from the issue.