Skip to content

Instantly share code, notes, and snippets.

@pccowboy
Created September 10, 2011 21:26
Show Gist options
  • Save pccowboy/1208814 to your computer and use it in GitHub Desktop.
Save pccowboy/1208814 to your computer and use it in GitHub Desktop.
Weird behavior using step
var nouvelle_conn;
Step(
function ha2() {
if (client._path != null) {
nouvelle_conn = tcp.createConnection(client._path);
} else {
nouvelle_conn = tcp.createConnection(client._port, client._host);
}
var self = this;
sys.puts('end of ha 2');
nouvelle_conn.on('connect', function() {
nouvelle_conn.on('data', self);
});
},
function ha3(err, d2, data) {
nouvelle_conn.removeAllListeners('data');
nouvelle_conn.setNoDelay(true);
var decoder = data.toReader();
status = decoder.int16();
version = decoder.int16();
len = decoder.int32();
console.log('connection to server version ' + version);
if (version < 1) {
err = new Error("Invalid Server version");
throw(err);
}
var version_number = Buffer.makeWriter();
version_number.push.int32(1);
nouvelle_conn.write(version_number.toBuffer(), '', this);
sys.puts('end of ha 3');
},
function ha4() {
sys.puts('_connect: ' + sys.inspect(nouvelle_conn));
sys.puts('end of ha 4');
return;
}
);
sys.puts('out of step, at least');
@pccowboy
Copy link
Author

Here is the output I get - the 'obj [object Object]' line is from the calling function:

end of ha 2
out of step, at least
'obj [object Object]'
_connect: { bufferSize: 0,
fd: 6,
type: 'tcp4',
allowHalfOpen: false,
_writeImpl: [Function],
_readImpl: [Function],
_shutdownImpl: [Function],
_readWatcher:
{ socket: [Circular],
callback: [Function: onReadable] },
destroyed: false,
readable: true,
_writeQueue: [],
_writeQueueEncoding: [],
_writeQueueFD: [],
_writeQueueCallbacks: [],
_writeWatcher:
{ socket: [Circular],
callback: [Function: onWritable] },
writable: true,
_connecting: false,
_events:
{ connect: [Function],
error: [Function],
end: [Function],
data: null } }
end of ha 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment