|
| 1 | +============ |
| 2 | +Known Issues |
| 3 | +============ |
| 4 | + |
| 5 | +This page lists known issues in mod_wsgi itself: confirmed defects and |
| 6 | +accepted limitations in the module, as opposed to problems in your |
| 7 | +Apache configuration or your WSGI application. If you are still working |
| 8 | +out *where* a problem lives, start with :doc:`troubleshooting`; the |
| 9 | +guides it links to cover installation, configuration, and application |
| 10 | +problems, which are far more common than bugs in mod_wsgi. |
| 11 | + |
| 12 | +An issue is listed here when the behaviour is understood, there is |
| 13 | +nothing a user can do to make mod_wsgi behave differently beyond the |
| 14 | +noted workaround, and a full fix is either not yet available or not |
| 15 | +considered worthwhile. Each entry records the symptom, which mode of |
| 16 | +operation is affected, the underlying cause, any workaround, and the |
| 17 | +current status with a link to the tracking issue. |
| 18 | + |
| 19 | +If you are hitting something that is not listed here and not explained |
| 20 | +by :doc:`troubleshooting`, see :doc:`reporting-bugs`. |
| 21 | + |
| 22 | +.. _known-issue-chunked-truncation: |
| 23 | + |
| 24 | +Truncated chunked responses are not signalled to the client in daemon mode |
| 25 | +-------------------------------------------------------------------------- |
| 26 | + |
| 27 | +**Symptom** |
| 28 | + |
| 29 | +A WSGI application streams a response with no ``Content-Length`` header, |
| 30 | +so it is sent to the client using ``Transfer-Encoding: chunked``. If the |
| 31 | +response is then cut short partway through, the client still receives a |
| 32 | +syntactically complete chunked response, terminated with the final |
| 33 | +``0`` chunk, and cannot tell that the body was truncated. The response |
| 34 | +is cut short when either: |
| 35 | + |
| 36 | +* the application raises an unhandled exception while iterating the |
| 37 | + response, or |
| 38 | +* the daemon process handling the request dies mid-response (for |
| 39 | + example, it is killed, crashes, or hits a resource limit). |
| 40 | + |
| 41 | +**Affected mode** |
| 42 | + |
| 43 | +Daemon mode only. In embedded mode this was addressed in version 4.4.0: |
| 44 | +when a chunked response is interrupted by an application exception, |
| 45 | +mod_wsgi suppresses the terminating ``0`` chunk so the client sees an |
| 46 | +unterminated response and can detect the truncation. Responses that do |
| 47 | +carry a ``Content-Length`` are not affected in either mode, because a |
| 48 | +client can already detect a short read against the declared length. |
| 49 | + |
| 50 | +**Cause** |
| 51 | + |
| 52 | +In daemon mode the response is produced in the daemon process and |
| 53 | +proxied back to the Apache child process over a socket, with the chunked |
| 54 | +framing toward the client applied by the Apache child. The response leg |
| 55 | +between daemon and child is an unframed byte stream whose end is |
| 56 | +signalled only by the socket closing, so a clean completion, an |
| 57 | +application exception, and an outright crash all look identical to the |
| 58 | +Apache child. The child then terminates the chunked response toward the |
| 59 | +client normally. The embedded-mode fix does not carry over because it |
| 60 | +acts in the daemon process, on a different request, from where the |
| 61 | +client-facing chunked framing is applied. |
| 62 | + |
| 63 | +**Workaround** |
| 64 | + |
| 65 | +Where it matters that a client can detect a truncated response, have the |
| 66 | +application set a ``Content-Length`` header so the response is not sent |
| 67 | +chunked; a client can then detect a short read against the declared |
| 68 | +length. This is only possible when the response length is known in |
| 69 | +advance. |
| 70 | + |
| 71 | +**Status** |
| 72 | + |
| 73 | +Open. A fix would require framing the daemon-to-child response leg so the |
| 74 | +Apache child can distinguish a truncated response from a clean one and |
| 75 | +withhold the terminating ``0`` chunk. The value of such a fix is limited |
| 76 | +in any case: chunked transfer encoding is hop by hop, so an intermediary |
| 77 | +proxy may dechunk and re-chunk the response and append its own |
| 78 | +terminating chunk, which would erase the truncation signal before it |
| 79 | +reaches the client. Tracked as |
| 80 | +`issue #42 <https://github.com/GrahamDumpleton/mod_wsgi/issues/42>`__. |
0 commit comments