-
Notifications
You must be signed in to change notification settings - Fork 406
Move reading of multipart response into try body
#19062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix a bug introduced in 1.111.0 where failed attempts to download authenticated remote media would not be handled correctly. |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1719,6 +1719,7 @@ async def federation_get_file( | |||||||||||
| response, output_stream, boundary, expected_size + 1 | ||||||||||||
| ) | ||||||||||||
| deferred.addTimeout(self.default_timeout_seconds, self.reactor) | ||||||||||||
| multipart_response = await make_deferred_yieldable(deferred) | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be inside the Maybe. We do it in synapse/synapse/http/matrixfederationclient.py Lines 1578 to 1582 in da6c0ca
And although this isn't explained anywhere, I guess the point of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would argue yes. This code: # add a byte of headroom to max size as `_MultipartParserProtocol.dataReceived` errs at >=
deferred = read_multipart_response(
response, output_stream, boundary, expected_size + 1
)
deferred.addTimeout(self.default_timeout_seconds, self.reactor)merely sets up the download, whereas: multipart_response = await make_deferred_yieldable(deferred)is where we actually wait for the download to complete. So I would expect the lineariser to cover the latter. I can't speak to why we limit the number of downloads. Potentially the limit the number of open file descriptors? But 6 seems quite low for only that reason. 🤷 |
||||||||||||
| except BodyExceededMaxSize: | ||||||||||||
| msg = "Requested file is too large > %r bytes" % (expected_size,) | ||||||||||||
| logger.warning( | ||||||||||||
|
|
@@ -1755,7 +1756,6 @@ async def federation_get_file( | |||||||||||
| ) | ||||||||||||
| raise | ||||||||||||
|
|
||||||||||||
| multipart_response = await make_deferred_yieldable(deferred) | ||||||||||||
| if not multipart_response.url: | ||||||||||||
| assert multipart_response.length is not None | ||||||||||||
| length = multipart_response.length | ||||||||||||
|
|
||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have tests for this kind of timeout? (just wondering)
It looks like this was previously functional and the only problem was the unexpected logs/error handling so a high-level integration/end-to-end test wouldn't have really prevented this.
It looks like we already have other tests in
tests/http/test_matrixfederationclient.pythat ensure we raise aRequestSendFailedin certain scenarios. We could add one of those 🤷There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pointer to the test file. I've written up a test (that fails on
develop) in 1f20fe7.