Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Tests doesn't pass and exit with a timeout exception #519
I run 'make test' and I get:
make: Entering directory `/home/feri/wwwroot/socket.io' . info - socket.io started uncaught: Error: 'test handshake' timed out at Object._onTimeout (/home/feri/wwwroot/socket.io/node_modules/expresso/bin/expresso:844:43) at Timer.callback (timers.js:62:39)
Testing stops, so tests doesn't continue to run after this exception. (but the test suite doesn't exits, just waits and waits)
Is there anything I can do to help fix the tests on Linux? Any clues to what the problem might be?
I'd like to write more tests and a few features that I need for our deployment, and would definitely prefer not starting a second set of tests to work around this.
If you can point me to the right direction, I'll do what I can to figure it out.
I would prefer to have this on Node 0.4 as well, and I figured it out, the problem is that on OSX, libev seems to use a different backend which results in different behavior. Basically:
Since the tests try to connect immediately without passing control back to the Node event loop, on Linux the server won't be started when the client tries to connect. Then the ECONNREFUSED error gets discarded, so nothing happens
Note that according to node.cc (v.0.4.12), if you have OSX 10.6, then EVBACKEND_KQUEUE is used, but otherwise EVFLAG_AUTO is set, which defines the default backend as whatever libev deems appropriate.
Can I fix this and send a pull request? I'd love to have the mainline tests work on older Node.js versions, since that's what we're on.
The fix involves adding a process.nextTick() wrapper somewhere in the tests. Here is an example for the first test:
Can I add the process.nextTick() to the tests, or would you prefer some other way, e.g. by adding the wrapper to client.handshake() where possible? I'm not particularly familiar with the tests but I think I could just add the wrapper to common.js that delays execution of the client code until nextTick(), at least where the tests start with a handshake. Is that OK?
I guess the correct solution would be to alter create() to accept a callback to run after is has been started, since then the test won't rely on undefined behavior (e.g. what happens when httpServer.listen() but control has not been passed back to the event loop). That would prevent the problem from reoccurring, though this requires a lot of tests to be restructured. The current tests rely on a platform-specific behavior in the backend which means they can break again if the libev backend is switched.