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

Handling "IOError: request data read error" when user cancels a request #6

Open
StephenChan opened this issue Oct 16, 2012 · 0 comments

Comments

@StephenChan
Copy link
Collaborator

The production server (which runs on Apache + mod_wsgi) occasionally gets this error.

As far as I know, though, this error doesn't indicate a disruption of the user experience. It happens when the user starts a POST request, and then the user stops the request before it completes (by navigating to another page, clicking the Stop button on their browser, their internet going down, etc.). The error has occurred most often on the image upload and annotation import pages, probably because uploading images means making a request that takes longer, and longer requests are more likely to be cancelled by the user.

So I'm posting this error as an issue, but I'm saying the error itself isn't really an issue. Well, here's what the issue is:

Every time this error occurs, the site admins get emailed, and the error is reported in the Sentry client. There should be a way to tell Django to stop reporting this error, at least so our inboxes don't get "false-positive" error emails. Ideas:

(1) Gracefully catch the IOError. Ideally as close as possible in the call stack to the originating function, but we shouldn't go so far as to monkey-patch the Django framework code just for this. Perhaps check for the IOError in a decorator that wraps around every POST-request view. However, we'd have to be sure not to mask other possible kinds of IOErrors in the process.

(2) Tell the error logging to ignore errors with the particular text "IOError: request data read error" originating from a particular function. This route may not be as graceful, but seems like it'd be simpler to catch only a certain kind of IOError (but again, need to be careful).

I am leaning toward (2) at this point. But (1), if implemented with a good understanding of what's going on, could give a very good guarantee that we are only ignoring the IOError in the case of the user cancelling the request. Even (2) has the chance of falsely ignoring some "real" errors, if by coincidence there's another way to get the error of the exact same text + function origin.

Here's an example traceback of the error:

Environment:

Request Method: POST
Request URL: http://coralnet.ucsd.edu/images/source/49/upload/


Traceback:
File "<...>/django/core/handlers/base.py" in get_response
  105.                         response = middleware_method(request, callback, callback_args, callback_kwargs)
File "<...>/django/middleware/csrf.py" in process_view
  200.             request_csrf_token = request.POST.get('csrfmiddlewaretoken', '')
File "<...>/django/core/handlers/wsgi.py" in _get_post
  210.             self._load_post_and_files()
File "<...>/django/http/__init__.py" in _load_post_and_files
  272.                 self._post, self._files = self.parse_file_upload(self.META, self)
File "<...>/django/http/__init__.py" in parse_file_upload
  234.         return parser.parse()
File "<...>/django/http/multipartparser.py" in parse
  192.                         for chunk in field_stream:
File "<...>/django/http/multipartparser.py" in next
  314.             output = self._producer.next()
File "<...>/django/http/multipartparser.py" in next
  468.         for bytes in stream:
File "<...>/django/http/multipartparser.py" in next
  314.             output = self._producer.next()
File "<...>/django/http/multipartparser.py" in next
  375.             data = self.flo.read(self.chunk_size)
File "<...>/django/http/multipartparser.py" in read
  405.         return self._file.read(num_bytes)
File "<...>/django/http/__init__.py" in read
  296.         return self._stream.read(*args, **kwargs)

Exception Type: IOError at /images/source/49/upload/
Exception Value: request data read error
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

1 participant