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
Wrap ConnectionLost in a Failure for HTTP/2 #1265
Conversation
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.
@clokep it looks like there are other places this is happening - would it be worth cleaning up the others while we are here?
@richvdh I'll take another look and see if I can find more. |
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 so much for your contribution! This does look like an obviously correct fix, but we should really have some automated test changes to go along with it to make sure we keep this behavior.
The good news is that I believe this code is already tested, it's just not looking at the values of its arguments - so if you could just add an assertion or two, that would be great!
@glyph Thanks for the feedback! I took a quick look at the test framework and starting dissecting one of the tests: Weirdly this seems to be checking for the desired type already. (This would be to match the change here: https://github.com/twisted/twisted/pull/1265/files#diff-4872b70e1efa2de2dd576dff031f2ef0L352 ). I've traced the value through to the point where it hits |
I spent a bit more time debugging this and what is happening on
So I think this normally works "fine", but isn't fully correct. Note that the reason Synapse hit this (matrix-org/synapse#7441) is because a custom Unfortunately I'm not sure this gets me closer to being able to test this, but explains why the tests already see this as working correctly. |
I should likely summarize my issue a bit better: I'm unsure how to add an assertion that |
So, the way to ask this is "for whom is it a problem", i.e. what is it that might application code do where it will see the difference? As it is… I'm not actually sure that public application code can see this. A subclass of H2Connection might see the distinction, but… you can't actually subclass H2Connection without importing a private implementation detail, not covered in the documentation or exported in For type-correctness we should still be doing this, because when we type-hint
Given that this is effectively an internal implementation detail though, not something that the public interface of Twisted actulaly exposes, I would say that the news fragment ought to be a |
This seems like the most promising approach to me -- unfortunately
I'll look at it more though, that was just from a quick test! |
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.
This change looks correct.
In your tree, before pushing to GitHub, can you run:
tox -e lint
And fix a few style errors (lines too long) which are showing up as errors during CI?
I think I had a chat over IRC about this originally...the changes kind of snowball once I do that, but it was easy enough! I've pushed a commit which fixes lint + merged in trunk again. |
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.
Looks good. Lint now passes
@rodrigc I definitely agree! I'm glad to see that Twisted is starting to adopt type annotations. I've find them to be very useful in a large-ish project. (Especially ones where you care about bytes vs. str.) Thanks for working on this (and for the review!) |
Thanks for all the help! 🎉 |
Contributor Checklist:
review
to the keywords field in Trac, and putting a link to this PR in the comment; it shows up in https://twisted.reviews/ now.