-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat: fixes exception due to unread bytes in stream #1897
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1897 +/- ##
=======================================
Coverage 92.19% 92.19%
=======================================
Files 27 27
Lines 3099 3100 +1
Branches 554 555 +1
=======================================
+ Hits 2857 2858 +1
Misses 169 169
Partials 73 73
Continue to review full report at Codecov.
|
Note: this is already fixed in #1876 (streaming branch) which prints a proper diagnostic and no traceback:
This PR is still useful because the streaming branch is postponed until Sanic 21.03 or so. |
Yes we still need a fix for the current branch to patch between 20.9 and 20.12 since that branch is set for 21.3 |
@imgurbot12 Could you add tests so that this has 100 % patch coverage? |
Hi @Tronic, very sorry about the delay. I'm afraid I'm not very familiar with this sort of testing coverage benchmark. What tests do I need to improve/write to add coverage for the single line that I've added? I can't seem to find any tests in |
Can you add another function in Coverage comes automatically from all lines of code actually hit by at least a single test case. |
hrm. Well it seems like the unit-tests passed. I'm not sure whats wrong with the linter that's causing it to error now |
Run |
@ahopkins That should hopefully be the last of the automated changes lol. Thanks |
Thanks for this. Will get it merged once the tests are done. |
Yeah no problem! Glad to help out :) |
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.
Tests should use the test client whenever possible, so that they don't break when server's internal implementation is modified as long as the external functionality stays the same.
Hi there! I noticed that the stream handlers for sanic seem to raise an exception when stream data is not read entirely or the request is cancelled for whatever reason, which was annoying me slightly so I found an easy fix and am hoping to get it merged into master.
I have a test script to replicate the error. There are two functions in the example server instance.
works
will run just fine without any tracebacks because it reads all of the stream dataerrror
will raise a traceback due to the fact that the request object gets deleted after request completion, but the byte-reader is still active because there is still data in the bufferFix Description:
I fixed it by simply adding an additional check that will ignore any request operations if the request object is no longer present
allowing the remaining bytes in the buffer to simply be discarded.
Example Traceback:
Sample Script for Replication of Error:
Sample Requests Made w/ Curl: