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

Task was destroyed but it is pending! #24

Closed
micahdlamb opened this issue Nov 17, 2019 · 11 comments
Closed

Task was destroyed but it is pending! #24

micahdlamb opened this issue Nov 17, 2019 · 11 comments

Comments

@micahdlamb
Copy link

micahdlamb commented Nov 17, 2019

I'm running a pretty simple quart app with hypercorn on a RHEL7 linux server.
quart = 0.10.0
hypercorn = 0.9.0

I keep seeing these messages printed to standard out randomly every couple requests.

Task was destroyed but it is pending!
task: <Task pending coro=<ProtocolWrapper.send_task() done, defined at /root/.local/share/virtualenvs/atomix-Zh2dG3yU/lib/python3.7/site-packages/hypercorn/protocol/__init__.py:58> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f08fc3db1d0>()]>>
Task was destroyed but it is pending!
task: <Task pending coro=<ProtocolWrapper.send_task() done, defined at /root/.local/share/virtualenvs/atomix-Zh2dG3yU/lib/python3.7/site-packages/hypercorn/protocol/__init__.py:58> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f08f55188d0>()]>>

I'm pretty sure it has to do with hypercorn because I don't see the messages when I run the app using app.run(...). I'm having trouble narrowing down the problem anymore than that... Is anyone else seeing these messages?

Every once in a while I have a json request fail. The response body is mysteriously empty. The content-length is set to the correct non 0 value but nothing is in the body. I'm not sure if its related to this or not.

@pgjones
Copy link
Owner

pgjones commented Dec 3, 2019

Sorry, I missed this issue.

I think this will happen if the client disconnects whilst the server is sending a response. These messages shouldn't be shown though, so this is a bug in Hypercorn.

When you see this happen, is there any evidence to prove/disprove that it is the client disconnecting?

@micahdlamb
Copy link
Author

I don't see any requests getting cancelled in the chrome dev tools. I still haven't been able to figure out what causes the messages. It just seems to happen randomly every couple requests.

@svenstaro
Copy link

I get the exact same problem. I can reproduce this every few requests using http or curl. I'm using hypercorn 0.9.0 with fastapi 0.43.0. Just curling a route will sometimes emit those errors in the console. I'm not sure whether these errors indicate that something harmful is going on or whether they are safe to ignore.

@pgjones
Copy link
Owner

pgjones commented Feb 29, 2020

I think this is fixed in the 0.9.2 release, could you check?

@thewhaleking
Copy link

Still seeing this as of 0.9.2

@pgjones
Copy link
Owner

pgjones commented Mar 3, 2020

The send_task, which sends the HTTP/2 data according to the prioritization could get blocked when the connection closed - leading to this warning. It should be fixed with 1e350e4, could you check?

@thewhaleking
Copy link

Testing this out today. Will update by EOD with results.

@thewhaleking
Copy link

thewhaleking commented Mar 3, 2020

Well, that didn't take long:

2020-03-03 08:00:03,542 :: ERROR :: Task was destroyed but it is pending!
task: <Task pending name='Task-40' coro=<ProtocolWrapper.send_task() done, defined at /home/bhimes/Gits/hardware-tooling/venvhypercorn/lib/python3.8/site-packages/hypercorn/protocol/__init__.py:58> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f33554e5eb0>()]>>

Started up the hypercorn server (running Quart), clicked around a few of the links in my web app, was working fine. Walked away from my computer and made myself coffee. Came back, clicked another link (same session, browser, window, etc.), instantly this. Note that the page still loaded fine (they really always do), but yet still getting that error in the log.

EDIT: Confirmed that this dev version does include 1e350e4. From /home/bhimes/Gits/hardware-tooling/venvhypercorn/lib/python3.8/site-packages/hypercorn/protocol/h2.py

    async def _close_stream(self, stream_id: int) -> None:
        if stream_id in self.streams:
            stream = self.streams.pop(stream_id)
            await stream.handle(StreamClosed(stream_id=stream_id))
            await self.has_data.set()

These are all h2 in Chrome btw.

@pgjones
Copy link
Owner

pgjones commented Mar 23, 2020

Ok, so I'm now confident that 0.9.3 has fixed this.

@thewhaleking
Copy link

Bumped to 0.9.3, testing today, will report results.

@thewhaleking
Copy link

I've seen no errors in the last day. I think you may have indeed solved it.

@pgjones pgjones closed this as completed May 12, 2020
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

No branches or pull requests

4 participants