test: improve test-cluster-net-send.js#9570
Conversation
shigeki
left a comment
There was a problem hiding this comment.
CI submitted by @mscdex was running on https://ci.nodejs.org/job/node-test-pull-request/4828/ . Two tests were failed, one is due to missing g++ in CentOS7-64 build env and others Jenkins error on armv8. Others are fine. LGTM.
There was a problem hiding this comment.
Instead of 127.0.0.1, couldn't you use server.address().address?
cjihrig
left a comment
There was a problem hiding this comment.
LGTM, but it looks like there are a few other improvements that could be made to this test (var -> const, common.mustCall(), assert.strictEqual(), etc.).
9829c3c to
27ad46b
Compare
|
@cjihrig |
There was a problem hiding this comment.
Now that you have added the common.mustCall wrapper I think you can remove the called variable.
Also, though highly unlikely, the data listener could be called more than once, so I would check for the data validity in the end listener.
There was a problem hiding this comment.
Yes, drop the called variable and the process.once('exit', ...), move the common.mustCall() from the data handler to the end handler, and do a concatenation in the data handler.
There was a problem hiding this comment.
Isn't this unreachable code?
It would be better to have the process exit naturally, rather than call process.exit().
There was a problem hiding this comment.
Can you add common.mustCall() here too. Otherwise, there is no guarantee that the process.once('message', ...) handler is added.
There was a problem hiding this comment.
common.mustCall() here as well.
27ad46b to
d7f29a0
Compare
|
@cjihrig @santigimeno @jasnell |
|
CI is running again on https://ci.nodejs.org/job/node-test-pull-request/4909/ . |
|
The test fails on Windows: https://ci.nodejs.org/job/node-test-binary-windows/4954/RUN_SUBSET=3,VS_VERSION=vs2015,label=win2008r2/tapTestReport/ Example output on my PC: |
|
@akito0107 can you please take a look at the windows test failure? |
3927897 to
644967c
Compare
This commit improves test-cluster-net-send as below - change function to arrow function - ensure data event is emitted exactly once
644967c to
fbd8c9f
Compare
|
@jasnell This error might be caused by using |
| server.listen(common.PORT, function() { | ||
| socket = net.connect(common.PORT, '127.0.0.1', socketConnected); | ||
| server.listen(common.PORT, () => { | ||
| socket = net.connect(server.address().port, server.address().address, |
There was a problem hiding this comment.
I think this is the same issue as the one I saw in #10854
If so, the problem is that you can't use server.address().address here. You should be listening on 0 (i.e. all IPv6 and IPv4 addresses), in which case server.address().address resolves to ::. On linux this sometimes resolves to 127.0.0.1 if there is no IPv6 support on the machine, but this isn't the case on all platforms.
Changing to:
- server.listen(common.PORT, () => {
- socket = net.connect(server.address().port, server.address().address,
+ server.listen(0, () => {
+ socket = net.connect(server.address().port, 'localhost',should fix the issue on all platforms. localhost should always resolve to either 127.0.0.1 or :: (either of which is fine).
cc/ @cjihrig
|
Ping... status update on this one? |
|
There hasn't been any activity here. I'm closing this. Feel free to reopen (or ping a collaborator) if I closed this in error. |
Checklist
make -j8 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
test, cluster
Description of change
This commit improves test-cluster-net-send as below;
This is a part of Code And Learn at NodeFest 2016 Challenge
nodejs/code-and-learn#58