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

HttpResponse.outputStream.close should work even if HttpRequest.inputStream isn't drained #6984

Closed
nex3 opened this issue Nov 27, 2012 · 15 comments
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io P1 A high priority bug; for example, a single project is unusable or has many test failures
Milestone

Comments

@nex3
Copy link
Member

nex3 commented Nov 27, 2012

Full error output:

Unhandled exception:
HttpParserException: Connection closed before full request body was received

­0 _HttpServer.listenOn.onConnection.<anonymous closure> (dart:io:3316:11)

­1 _HttpConnection._onError._onError (dart:io:3235:12)

­2 _HttpParser.streamDone.streamDone (dart:io:4607:12)

­3 _SocketBase._multiplex (dart:io-patch:399:26)

­4 _SocketBase._sendToEventHandler.<anonymous closure> (dart:io-patch:500:20)

­5 _ReceivePortImpl._handleMessage (dart:isolate-patch:37:92)

@munificent
Copy link
Member

Added Accepted label.

@munificent
Copy link
Member

cc @madsager.
Added Started label.

@munificent
Copy link
Member

Hey, Mads. Can you take a look at this? I spent a few minutes on it, but the bowels of dart:io are a mystery to me. If you want to repro this, just remove this from utils/tests/pub/pub.status:

  # TODO(nweiz): The "pub lish" tests fail mysteriously on OS X. See issue #6984.
  [ $system == macos ]
  pub_lish_test: Fail

And then run:

dart utils/tests/pub/pub_lish_test.dart

It repros 100% of the time.


cc @nex3.
Set owner to @madsager.
Added Triaged label.

@madsager
Copy link
Contributor

cc @sgjesse.

@madsager
Copy link
Contributor

There is one clear issue here. The server request handler does not read the request body. That will cause the error you are seeing here. So for all of your request handlers you should add:

request.inputStream.onData = request.inputStream.read();
request.inputStream.onClosed = response.close();

instead of just

response.close();

That will read and discard the data that you are not interested in. We might want to change dart:io so that the server can just close the response and ignore the data from the client. That will however give an error on the client when he cannot write his data. So for this test it seems best in any case to read the data in the server request handlers.

There seems to be one other issue that I didn't get the time to get to the bottom of. 'cloud storage upload provides an error' ends up not being able to get the data from the request. It seems that it works fine if the call to write on the response output stream is removed. That doesn't make much sense and we haven't been able to repro with pure dart:io client and server code.

@nex3
Copy link
Member Author

nex3 commented Nov 28, 2012

If it's an error to close the request input stream without reading it, why doesn't that error appear on Linux?

@madsager
Copy link
Contributor

Probably timing. On Linux the data might make its way through the parser before the close in which case you will not get the error. Another reason why it probably shouldn't be an error on the server side to just discard the request if you want to ignore the data.

@madsager
Copy link
Contributor

I looked into the last remaining failure that I consistently have on my Mountain Lion Mac. It turns out that curl does not like that you write something to it as a response before it is done sending its data. This might be a Mac specific curl issue. I have attached two files that reproduces this for me consistently.


Attachments:
curl.dart (819 Bytes)
server.dart (698 Bytes)


Set owner to @nex3.

@nex3
Copy link
Member Author

nex3 commented Nov 30, 2012

r15476 works around this in Pub, so I'm going to make this a bug against dart:io to fix the underlying issue.


Removed the owner.
Removed Area-Pub label.
Added Area-IO label.
Changed the title to: "HttpResponse.outputStream.close should work even if HttpRequest.inputStream isn't drained".

@madsager
Copy link
Contributor

Thanks Nathan!


Set owner to @sgjesse.

@sgjesse
Copy link
Contributor

sgjesse commented Dec 3, 2012

Added Started label.

@sgjesse
Copy link
Contributor

sgjesse commented Dec 6, 2012

Fixed in http://code.google.com/p/dart/source/detail?r=15782-


Added Fixed label.

@nex3
Copy link
Member Author

nex3 commented Dec 7, 2012

This still seems to be occurring. I tried removing all the workarounds for it in r15804 and the Pub curl tests started flaking again on OS X: http://build.chromium.org/p/client.dart/builders/pub-mac/builds/1277/steps/pub%20tests%20failures/logs/stdio.


Added Triaged label.

@sgjesse
Copy link
Contributor

sgjesse commented Dec 11, 2012

This should now be fixed in http://code.google.com/p/dart/source/detail?r=15951.

The problem with the fix from #­12 (http://code.google.com/p/dart/source/detail?r=15782) was that it broke the protocol as the server closed the connection without including the Connection header with the close token.


Added Fixed label.

@kevmoo
Copy link
Member

kevmoo commented May 14, 2014

Removed Area-IO label.
Added Area-Library, Library-IO labels.

@nex3 nex3 added Type-Defect P1 A high priority bug; for example, a single project is unusable or has many test failures area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io labels May 14, 2014
@nex3 nex3 added this to the M2 milestone May 14, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

5 participants