Skip to content
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

Fix a RuntimeWarning exception raised when calling ThreepidBinder._notify without awaiting #552

Merged
merged 2 commits into from
Mar 1, 2023

Conversation

anoadragon453
Copy link
Member

When an error occurred while informing a homeserver of a successful bind between a Matrix ID and a third-party ID, Sydent should log the error and retry the request to the homeserver.

Right now this is broken, and Sydent will raise a RuntimeWarning due to ThreepidBinder._notify not being await'd:

2023-02-28 11:41:47,501 - sydent.threepid.bind - 214 - WARNING - Error notifying on bind for @admin:localhost: Connection was refused by other side: 111: Connection refused. - rescheduling
/home/work/.cache/pypoetry/virtualenvs/matrix-sydent-RILnZfem-py3.10/lib/python3.10/site-packages/twisted/internet/base.py:991: RuntimeWarning: coroutine 'ThreepidBinder._notify' was never awaited
  call.func(*call.args, **call.kw)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

This would call the request to never be retried as well, breaking reliability.

This PR fixes the call to ThreepidBinder._notify so that it is properly awaited via defer.ensureDeferred. The self.sydent.reactor.callLater(...) call is used for backing off purposes, and expects a Callable, not a Coroutine, hence the use of something like defer.ensureDeferred.

@anoadragon453 anoadragon453 marked this pull request as ready for review February 28, 2023 11:46
@anoadragon453 anoadragon453 requested a review from a team as a code owner February 28, 2023 11:46
Copy link
Contributor

@DMRobertson DMRobertson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way we could have spotted this---testing, I suppose?

@anoadragon453
Copy link
Member Author

anoadragon453 commented Mar 1, 2023

Yes, we should write a test to ensure that homeserver callbacks on bind get retried. This was a drive-by fix though, and I'm not likely to get around to that in a while.

So I've left an issue instead: #554

@anoadragon453 anoadragon453 merged commit 46d8a7a into main Mar 1, 2023
@anoadragon453 anoadragon453 deleted the anoa/call_notify_async branch March 1, 2023 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants