node-tosource icon indicating copy to clipboard operation
node-tosource copied to clipboard

Fix native code

Open chientrm opened this issue 3 years ago • 1 comments

In my case, the output contains function () { [native code] } so that it's invalid to be read by the browser.

chientrm avatar Jul 08 '22 14:07 chientrm

This is very bizarre. I wonder why there is a performance difference, because if you look at the source for net.createConnection:

exports.connect = exports.createConnection = function(port /* [host], [cb] */) {
  var s;

  if (isPipeName(port)) {
    s = new Socket({ handle: createPipe() });
  } else {
    s = new Socket();
  }

  return s.connect(port, arguments[1], arguments[2]);
};

And on 0.4.12:

exports.createConnection = function(port, host) {
  var s = new Socket();
  s.connect(port, host);
  return s;
};

Can you submit your pull request anyway?

marcello3d avatar Jan 21 '12 19:01 marcello3d

I've sent a pull request. Let me know what you think.

Cowboy-coder avatar Jan 23 '12 11:01 Cowboy-coder

I've also created a ticket on node.js issue tracker. https://github.com/joyent/node/issues/2597

Cowboy-coder avatar Jan 23 '12 14:01 Cowboy-coder

For kicks, is it possible that the order in which the listeners and commands are added is affecting the speed? Did you try using your new patch and literally inlining the net.createConnection function body? (e.g. reverse patch on your patch)

marcello3d avatar Jan 28 '12 18:01 marcello3d