ConnectionAbortedError/asyncio.CancelledError when the page's loading is canceled by the user is not catchable.

Open
#230 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Start by running the issue's Quart example with Python 3.11.2, canceling the request during asyncio.sleep, and examining the linked traceback. Trace how the canceled request reaches Quart's error handling and compare that path with @app.errorhandler(ConnectionAbortedError). Done means cancellation is either suppressed as intended or exposes a documented, usable handling path without an uncaught error.

Written by the indexing model from the issue text.

Description

The error ConnectionAbortedError is thrown if the page's loading is canceled. Using @app.errorhandler(ConnectionAbortedError) with an appropriate function is completely ignored. How do I handle (or just suppress) this error?

reproducible example:

from quart import Quart
from time import sleep
import asyncio

app = Quart(__name__)

@app.route('/')
async def hello():
    await asyncio.sleep(1)
    return 'Hello, world!'

if __name__ == '__main__':
    app.run()

reproduce the bug:
run the script. connect to localhost:5000. cancel the load when the page is loading.

traceback: https://pastebin.com/aueksHyg

this error should not be thrown (or there needs to be a way to catch it.)

Environment:

  • Python version: 3.11.2
  • Quart version: 0.18.4
Dominant language
Python
Stars
3.7k
Forks
206
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pallets/quart

All issues in pallets/quart

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.