The destroy() method of fs.ReadStream and fs.WriteStream takes a callback.
It's a leftover from the node 0.1 days, undocumented and not part of the
streams API. Remove it.
Previously, a command with a short stdio array would result in the child's
stdout and stderr objects set to null. For example:
var c = child_process.spawn(cmd, args, {stdio: ['pipe']});
// results in c.stdout === null.
The expected behavior is the above line functioning the same as this one:
var c = child_process.spawn(cmd, args, {stdio: ['pipe', null, null]});
// provides correct (non-null) c.stdout; as does the above, after this fix.
This fixes the problem that calling pause() on a socket would not
actually prevent 'data' events from being emitted. It also replaces
the existing test by a more elaborate one.
Ref: #3118
Problem: calling `server.listen()` (no port) on a net.Server triggered the
following libuv assertion:
node: ../deps/uv/src/unix/stream.c:406: uv__write: Assertion `fd_to_send >= 0'
failed.
Cause: uv_tcp_t handles are lazily initialized. Omitting the port made the
handle get initialized even more lazily. Too lazily - it wasn't initialized
when the handle was sent over to the child process.
Solution: implicitly bind to a random port in listen() when the port number
is omitted, it forces the handle to initialize. This is not a change in
behavior, listen() has always been identical to listen(0).
Fixes #3325.
AssertionError already inherits from Error above using util.inherits(),
so this extra line was redundant.
test/simple/test-assert.js already tests for `instanceof`, and still passes.
This is rewrite of #3701 and #3603 before.
This patch introduce `util.inspect.styles`
and `util.inspect.colors` objects, which enables customization
of color sequences.
This reverts commit 928ea564d1.
Keeping the original Array instance in-place essentially causes a memory leak
on EventEmitters that use an infinite number of event names (an incrementing
counter, for example), which isn't an unreasonable thing to want to do.
Fixes #3702.
* don't assert when fd isn't an open file descriptor
* don't die with a ReferenceError when fd isn't a file descriptor
you can listen() on
Fixes #3699.
Before this commit, `fs.unwatchFile(path)` removed *all* listeners for `path`.
The function is overloaded now: `fs.unwatchFile(path)` still removes all
listeners, but `fs.unwatchFile(path, cb)` lets you remove a specific listener.
Fixes #3660.
Don't use the double-negate trick to coalesce the timeout argument into a
number, it produces the wrong result for very large timeouts.
Example:
setTimeout(cb, 1e10); // doesn't work, ~~1e10 == 1410065408
Wrong order of operands was causing problems while trying to use command
buffering:
> {
... a: 3,
...
repl.js:284
if (cmd.trim().match(/^npm /) && !self.bufferedCommand) {
^
TypeError: Cannot call method 'trim' of undefined
at finish (repl.js:284:17)
at REPLServer.self.eval (repl.js:118:5)
at rli.on.e (repl.js:260:20)
at REPLServer.self.eval (repl.js:118:5)
at Interface.<anonymous> (repl.js:250:12)
at Interface.EventEmitter.emit (events.js:88:17)
at Interface._onLine (readline.js:183:10)
at Interface._line (readline.js:502:8)
at Interface._ttyWrite (readline.js:720:14)
at ReadStream.<anonymous> (readline.js:105:12)
Test included.
Closes #3515.
Closes #3517.
Closes #3621.
There is no need for fs.readFile() to be using pread rather than read.
The default semantics of read() are such that subsequent reads are where
we want them anyway.
Make CLIENT_RENEG_LIMIT inclusive instead of exclusive, i.e. a limit of 2
means the peer can renegotiate twice, not just once.
Update pummel/test-tls-ci-reneg-attack accordingly and make it less timing
sensitive (and run faster) while we're at it.
Fix #3455.
The remoteAddress and remotePort properties are
dynamically retrieved from _getpeername().
While _getpeername() checks if the _handle is
null, it is also possible for the tcp_wrapped
_handle.getpeername() to return null on error.
Such a condition happens when the remote closes
and one of these properties is accessed before
_handle is set to null.
* V8: Upgrade to v3.11.10
* npm: Upgrade to 1.1.26
* doc: Improve cross-linking in API docs markdown (Ben Kelly)
* Fix #3425: removeAllListeners should delete array (Reid Burke)
* cluster: don't silently drop messages when the write queue gets big (Bert Belder)
* Add Buffer.concat method (isaacs)
* windows: make symlinks tolerant to forward slashes (Bert Belder)
* build: Add node.d and node.1 to installer (isaacs)
* cluster: rename worker.unqiueID to worker.id (Andreas Madsen)
* Windows: Enable ETW events on Windows for existing DTrace probes. (Igor Zinkovsky)
* test: bundle node-weak in test/gc so that it doesn't need to be downloaded (Nathan Rajlich)
* Make many tests pass on Windows (Bert Belder)
* Fix #3388 Support listening on file descriptors (isaacs)
* Fix #3407 Add os.tmpDir() (isaacs)
* Unbreak the snapshotted build on Windows (Bert Belder)
* Clean up child_process.kill throws (Bert Belder)
* crypto: make cipher/decipher accept buffer args (Ben Noordhuis)
When removeAllListeners is called, the listeners array
is deleted to maintain compatibility with v0.6.
Reverts "events: don't delete the listeners array"
This reverts commit 78dc13fbf9.
Conflicts:
test/simple/test-event-emitter-remove-all-listeners.js
Also, in the process, fix a bug in fs.realpath on Windows.
If the user has permission to create symlinks, then use symlinks. If
not, then skip over all the tests that cannot be run using Junctions
instead.
This implements server.listen({ fd: <filedescriptor> }). The fd should
refer to an underlying resource that is already bound and listening, and
causes the new server to also accept connections on it.
Not supported on Windows. Raises ENOTSUP.
* When the process is already dead, but the `exit` signal wasn't raised
yet, the ESRCH error should be ignored.
* When an invalid signal is specified, kill() should throw.
* Like process.kill(), child_process.kill() now preserves a `0` signal
which can be used to check the liveliness of the child process.
* process.kill() and child_process.kill() will now return true if the
signal was actually delivered, and false otherwise.
* When an `exec`-ed process is automatically killed because a time or
buffer limit is exceeded, and the kill() fails, this error should be
reported through the `exec` callback.
Fixes: #3409
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> }"
});
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.