Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Unhandled error in Deferred: BodyExceededMaxSize #9095

Closed
richvdh opened this issue Jan 12, 2021 · 3 comments · Fixed by #9108
Closed

Unhandled error in Deferred: BodyExceededMaxSize #9095

richvdh opened this issue Jan 12, 2021 · 3 comments · Fixed by #9108
Assignees

Comments

@richvdh
Copy link
Member

richvdh commented Jan 12, 2021

We're seeing a few of these in the logs from the federation sender:

2021-01-12 21:41:24,475 - twisted - 254 - CRITICAL - None - Unhandled error in Deferred:
2021-01-12 21:41:24,485 - twisted - 254 - CRITICAL - None - 
synapse.http.client.BodyExceededMaxSize
@richvdh
Copy link
Member Author

richvdh commented Jan 12, 2021

it looks like we should be catching BodyExceededMaxSize, so maybe it's something like: we are aborting the request, but failing to cancel it: it then goes on in the background until we get a huge response?

@richvdh
Copy link
Member Author

richvdh commented Jan 12, 2021

or possibly: we are correctly catching the BodyExceededMaxSize, but it is being thrown again into a second deferred:

    def dataReceived(self, data: bytes) -> None:
        self.stream.write(data)
        self.length += len(data)
        if self.max_size is not None and self.length >= self.max_size:
            self.deferred.errback(BodyExceededMaxSize())
            self.deferred = defer.Deferred()
            self.transport.loseConnection()

... replacing self.deferred in that way seems risky. Calling loseConnection does not, afaik, guarantee that dataReceived will not be called again.

@clokep
Copy link
Contributor

clokep commented Jan 13, 2021

This is probably happening more now due to checking the well known size. (I had noticed there's a few servers that are offline and redirect to large 404 pages...) I'll take a look at this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants