joyent/node — Issue #2658: ServerRequest not being closed properly?
Author: craigyk
Created: 2012-02-01 02:41:27+00:00
State: open

I'm trying to send a large file using XHR. If the file being sent fails some tests on the receiving end I want to close the incoming request after sending an appropriate error response (i.e. 500).

Unfortunately I tried several options that do not work reliably, the XHR client might get the 500 code and abort the upload (desired behavior) but it might also not abort the upload, or it might abort without displaying the sent response.

1. I tried just sending an error response and closing the response
results: sometimes the XHR upload aborts with the error code, sometime it just keeps on going
2. I tried setting allowHalfOpen to false in the hope that it would close the incoming socket when the response was sent
results: sometimes the XHR aborts (without showing response error), sometimes it continues (if file upload size is large)
3. I tried setting the 'Connection' header to 'close' in the response
results: in this case the XHR always stops, but does not return the response code

I thought it might be a bug in the XHR handling, but firefox and webkit show identical behaviour.

some code of the error:
https://gist.github.com/1713802