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
Start HttpServer in runZoned() causing uncaught error if the client closes the connection #17468
Comments
Hi, This code appears to be working with bleeding-edge. However, I'm not 100% sure if this is due to a actual fix, or changes that made this test not hit it anymore. Keep open for now, for further investigations.
|
This comment was originally written by @tomyeh Confirmed it doesn't throw the exception (r33495). However, neither the catchError of response.done nor onError catch the socket exception either. In one of the old versions (I don't recall), done is the right place to catch this kind of abnormal connection termination. Or, in the current spec, it is ignored silently? |
It's ignored silently. :) |
This comment was originally written by @tomyeh Then, how about if the user closed the browser before completing a long download? Will the server keep reading and sending if without this exception? |
Depends:
|
This comment was originally written by @tomyeh Got it. Thanks. |
I'm closing this for now, as I'm unable to reproduce this. Please file a new one or open this one again, if you're able to somehow reproduce! Thanks!
|
This comment was originally written by @tomyeh Unfortunately, one of users reports a server crash with Dart 1.3 at http://stackoverflow.com/questions/22977471/rikulo-stream-crashes-daily-with-socketexception-os-error-broken-pipe-errno As he reported, here is stacktrace after upgrading to Dart 1.3 Uncaught Error: SocketException: OS Error: Connection reset by peer, errno = 104, address = 0.0.0.0, port = 80 |
This comment was originally written by @tomyeh One of our engineers leaves the server running idly overnight (no request at all during this period). On the second day, Dart VM was dead with the following stack trace: Uncaught Error: SocketException: Write failed, address = 0.0.0.0, port = 8081 |
Fixed in r35071. Thanks for linking to the SO thread, helped me identify the issue. Added Fixed label. |
This comment was originally written by ses...@gmail.com Do you schedule a Dart 1.3.1 release with this patch ? |
A 1.3 release is scheduled with this fix. |
A release with the fix has been sent out on the dev channel today (1.4.0-dev.3.0). It would be great if you could give us feedback on whether or not the issue has been resolved in that release -- so that we know if back porting the fix to the stable channel (1.3.x) is going to help. |
This comment was originally written by sestegr...@gmail.com I just upgraded to the latest Dart VM release from dev channel (1.4.0-dev.3.0). |
The fix has been shipped to the stable channel as part of version 1.3.6. |
This comment was originally written by ses...@gmail.com I installed Dart VM 1.3.6 on my 4 servers. Unhandled exception: |
Hi sestegra, Would it be possible for you to attach or email me a code snippet, that produces this error? Your program, is it only using HTTP, or is it also using WebSockets, etc? Having something more concrete will make it a lot faster for me, to find a fix for this issue! Thanks,
|
I looked into this some more, and have two more comments:
Thanks,
|
This issue was originally filed by @tomyeh
What steps will reproduce the problem?
Notice that both runZoned() and response.write() must be used. Otherwise, no error message will be shown (except "Simulate a long operation"). However, it is still wrong -- response.done.catchError() shall be able to catch the error (see Issue #5)
Dart VM version: 1.2.0 (Tue Feb 25 06:18:15 2014) on "windows_ia32"
Console log:
Simulate a long operation
Uncaught Error: SocketException: Write failed, address = 127.0.0.1, port = 8080
Unhandled exception:
SocketException: Write failed, address = 127.0.0.1, port = 8080
0 _rootHandleUncaughtError.<anonymous closure>.<anonymous closure> (dart:async/zone.dart:700)
1 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:23)
2 _asyncRunCallback (dart:async/schedule_microtask.dart:32)
3 _asyncRunCallback (dart:async/schedule_microtask.dart:36)
4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:119)
Test Code:
import "dart:async";
import "dart:io";
import "dart:async";
import "dart:io";
void main() {
HttpServer.bind("127.0.0.1", 8080).then((server) {
runZoned(() {
server.listen((request) {
final response = request.response;
response.done.catchError((err, stackTrace) {
print("Closing a connection by client shall reach here");
});
response.write("write something to cause the exception");
new Future.delayed(const Duration(seconds: 10), () {
print("Simulate a long operation");
response.close();
});
});
}, onError: (err, stackTrace) {
print("Uncaught: $err\n$stackTrace");
});
});
}
The text was updated successfully, but these errors were encountered: