tornadoweb / tornadoweb/tornado

Exceptions in data_received() (while using @stream_request_body) are not handled properly

Open
#1,223 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

web
Dominant language
Python
Stars
22.2k
Forks
5.6k
Avg merge
3h 42m
Merged PRs (30d)
16

Description

To overcome that, I use:

@stream_request_body
class RestoreHandler(RequestHandler):
    ...
    @gen.coroutine
    def data_received(self, chunk):
        try:
            yield buggy_operation()
        except Exception:
            self.set_header('Connection', 'close')
            self.set_status(413, 'Upload aborted')
            self.finish()
    ...

If I do not catch exception, connection silently aborted (as browser said). But instead, Tornado should respond with HTTP response and close connection.

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.

Research direction

Start by tracing Tornado's @stream_request_body handling and the data_received() exception path, then reproduce the behavior with the provided RestoreHandler example. Done means an uncaught exception during streamed request processing produces an HTTP response and closes the connection instead of silently aborting it.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.