Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

TCP.onread block when working with readline on v0.12.2 OSX #25492

Closed
rain1017 opened this issue Jun 9, 2015 · 3 comments
Closed

TCP.onread block when working with readline on v0.12.2 OSX #25492

rain1017 opened this issue Jun 9, 2015 · 3 comments

Comments

@rain1017
Copy link

rain1017 commented Jun 9, 2015

I make one tcp request when user input a line, but the TCP response is usually block until making next a few keystrokes. Tcpdump shows that the response packet has reached the client, but TCP.onread does not fired.
I use node v0.12.2, this is only happen in Mac OSX. Ubuntu is OK

echo server

var net = require('net');

var server = net.createServer(function(socket){
    socket.on('data', function(msg){
        console.log('%s', msg);
        socket.write(msg);
    });
});

server.listen(31017, '127.0.0.1');

client

console.log('Type anything then press enter, you should get response from echoServer immediately');
console.log('Sometimes TCP.onread may block until you make next keystroke');

var net = require('net');
var rl = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal : true,
});

var socket = net.createConnection({port : 31017});
socket.on('data', function(buf){
    console.log('=> %s', buf);
});

rl.on('line', function(line){
    socket.write(line);
})
.on('close', function(){
    socket.end();
    process.exit(0);
});
@rain1017
Copy link
Author

rain1017 commented Jun 9, 2015

I believe is a new bug in Node v0.12 on OSX.
Tested v0.10.36 on OSX, not repo.
v0.12 on Ubuntu, not repo.

@rain1017 rain1017 changed the title TCP.onread block when working with readline on MacOSX TCP.onread block when working with readline on v0.12.2 OSX Jun 9, 2015
@misterdjules
Copy link

Thank you @rain1017 for the detailed report! Confirmed bug, fixed by #25475. The fix should be included in the next release, node v0.12.5.

@misterdjules
Copy link

Closing as a duplicate of #9310.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants