When I start a server on a PORT in my tests and run it with testem sometimes this process gets orphaned.
This means that when I close testem and try to run the test again manually with npm test I get an EADDRINUSE error because the node process testem spawned is still running. Since testem was already closed this process has been orphaned and there is no way to kill it other then killall node or careful looking.
Yeah, I've seen this too. Problem is, it's up to the process that starts to server to clean up after itself. Testem sends a SIGTERM to the subprocess, but it's the responsibility of that process to handle SIGTERM and exit cleanly. Most test suites don't do this though because usually there is no need to. But for your case, since you are using something simple like tape, I'd try handling SIGTERM gracefully and see if that solves the problem.
@airportyh can't you just hard kill your child processes. Why not just ensure that they are not orphaned and have them automatically terminate when the parent process ends.
I'll play with it to get a good test case.
We had some students who are newer with node (and programming) running into this and it was rather confusing for them. We had to explain how to figure out the process id and kill it.
@wraithan I'd like to solve this. Could you give me more details on the scenario(s) that is causing this? Do a simple test was not enough to reproduce this for me.
Just ran into this problem today. Would appreciate a fix.
Hey, could you provide a simple repo / process script to reproduce this?
I can’t seem to be able to reproduce it. It only happened once. I am using tape. I guess there isn’t anything that can be done until the bug can be reproduced reliably.