Callbacks that were passed to the binding layer ran in the context of the
(internal) binding object. Make sure they run in the global context.
Before:
fs.symlink('a', 'b', function() {
console.log(this); // prints "{ oncomplete: [Function] }"
});
After:
fs.symlink('a', 'b', function() {
console.log(this); // prints "{ <global object> }"
});
In case a fd option is given to fs.createReadStream a read will instantly
happen. But in the edge case where fd point to an empty file and .pause()
was executed instantly, the end event would emit since no async wait was
between fs.createReadStream and the file read there emits end.
This is a cherry-pick of commit 1f3e4a7 into the v0.6 branch.
The server 'close' event was emitted before the last client 'close' event. Not
exactly fatal but potentially confusing.
Before this commit the order looked something like [client, server, client],
now it looks like [client, client, server].
See #3340 for more details.
In case a fd option is given to fs.createReadStream a read will instantly
happen. But in the edge case where fd point to an empty file and .pause()
was executed instantly, the end event would emit since no async wait was
between fs.createReadStream and the file read there emits end.
In case a worker would spawn a new subprocess with process.env, NODE_UNIQUE_ID
would have been a part of the env. Making the new subprocess believe it is a
worker, this would result in some confusion if the subprocess where to listen to
a port, since the server handle request would then be relayed to the worker.
This patch removes the NODE_UNIQUE_ID flag from process.env on startup so any
subprocess spawned by a worker is a normal process with no cluster stuff.
request.end() would sometimes try to write a zero-length buffer to the socket.
Don't do that, it triggers an unnecessary EPIPE when the other end has closed
the connection.
Fixes#3257.