Skip to content

Can't run tests on browsers. Fails with a 'SocketException.' #100

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

Closed
dynaxis opened this issue May 5, 2015 · 3 comments
Closed

Can't run tests on browsers. Fails with a 'SocketException.' #100

dynaxis opened this issue May 5, 2015 · 3 comments
Labels
needs-info Additional information needed from the issue author type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@dynaxis
Copy link

dynaxis commented May 5, 2015

I'm trying the 0.12.0 version of test package. When no -p option is specified, the test runs fine. But if I add -p, then tests fail with the stacktrace at the end of this report.

  • The browser passed to -p doesn't seem to affect the result
  • When no -p is given, the tests work well
  • All tests I tried don't contain anything available only on DartVM

Platform: WIndows 8.1 Pro K on x64
Dart version: 1.10.0_r45396 (from stable channel)
Steps to reproduce:

  1. Create any project and put a test/all_test.dart file (the content of all_test.dart is not significant in reproducing the problem).
  2. Run in the project root 'pub run test -p chrome test'
  3. The command fails with an error.
    Stacktrace:
c:\msys64\home\dynaxis\work\seed>pub run test -p firefox
Failed to create server socket (OS Error: Failed to start accept), address = loc
alhost, port = 0
dart:isolate  _RawReceivePortImpl._handleMessage

This is an unexpected error. Please file an issue at http://github.com/dart-lang
/test
with the stack trace and instructions for reproducing the error.
Unhandled exception:
Uncaught Error: SocketException: Failed to create server socket (OS Error: Faile
d to start accept), address = localhost, port = 0
Stack Trace:
#0      _NativeSocket.bind.<anonymous closure> (dart:io-patch/socket_patch.dart:
502)
#1      _RootZone.runUnary (dart:async/zone.dart:1155)
#2      _Future._propagateToListeners.handleValueCallback (dart:async/future_imp
l.dart:494)
#3      _Future._propagateToListeners (dart:async/future_impl.dart:577)
#4      _Future._completeWithValue (dart:async/future_impl.dart:368)
#5      _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:
422)
#6      _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#7      _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#8      _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
#9      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dar
t:143)

#0      _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:886)
#1      _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#2      _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#3      _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dar
t:143)
@nex3 nex3 added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) needs-info Additional information needed from the issue author labels May 5, 2015
@nex3
Copy link
Member

nex3 commented May 5, 2015

This looks like an underlying dart:io issue. Do you have any unusual network configuration, like a proxy or a firewall?

What happens when you run this code directly:

import "dart:io";

void main() async {
  var server = await HttpServer.bind("localhost", 0);
  print("serving on http://localhost:${server.port}");

  await for (var request in server) {
    request.response.write("Hello!");
    request.response.close();
  }
}

Can you successfully make an HTTP request to the server it starts?

@dynaxis
Copy link
Author

dynaxis commented May 6, 2015

@nex3, I just tried the above code after removing void from main(). 😁 And I get the same stacktrace. That means this is not an issue related to test package. RIght?

It seems something wrong on my side, though I don't have any peculiar proxy or network settings on my machine as far as I know. I tried to turn off Windows firewall but to no avail. A weird thing is the message says: Observatory listening on http://127.0.0.1:57359

Observatory seems to have succesfully opened a port, but not the Dart code. I'll dig more into this problem by myself, and share the result with others via Dart Misc or another bug report to a more relevant place. Thanks and sorry for wasting your time.

@dynaxis
Copy link
Author

dynaxis commented May 6, 2015

IPv6 is currently disabled on my machine. I don't know why. My current machine is directly connected to a port from my ISP and that's the only unusual setting it has.

On Windows, localhost resolves to an IPv6 address. That's why sockets can't be open on my machine. I don't know if any Dart package needs to handle cases like this. But I'm hit by the issue.

I've workarounded this issue by adding an explicit entry to Windows\System32\drivers\etc\hosts to resolve localhost to 127.0.0.1. So to me it's fine, but if you care to let my case handled, maybe using InetAddress.LOOPBACK_IP_V4 instead of localhost would help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-info Additional information needed from the issue author type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants