Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Domain stack fixes #4557

wants to merge 606 commits into from

Make domains a little safer by avoiding potentially unbounded stack bloat

The following code will cause the stack to grow:

var d = require("domain");

setTimeout(function() {
    console.log('domain stack length is now ' + d._stack.length);
}, 100);

d.create().run(function() {
    d.create().run(function() {
        d.create().run(function() {
            d.create().on("error", function(e) {
                console.log("caught " + e)
            }).run(function() {
                    throw new Error("died")
isaacs added some commits
@isaacs isaacs streams2: Tests of new interfaces 9b1b854
@isaacs isaacs streams2: ctor guards on Stream classes 545f512
@isaacs isaacs streams2: Allow Writables to opt out of pre-buffer-izing 0678480
@isaacs isaacs streams2: Support write(chunk,[encoding],[callback]) 71e2b61
@isaacs isaacs test: Writable bufferizing, non-bufferizing, and callbacks f3e71eb
@isaacs isaacs streams2: Fix regression from Duplex ctor assignment e82d06b
@isaacs isaacs test: fixture for streams2 testing acfb0ef
@isaacs isaacs streams2: flow() is not always bound to src cf0b4ba
@isaacs isaacs streams2: Use StringDecoder.end f624ccb
@isaacs isaacs streams2: Abstract out onread function 286aa04
@isaacs isaacs streams2: Fix duplex no-half-open logic 5856823
@isaacs isaacs streams2: Export Readable/Writable State classes 63ac07b
@isaacs isaacs streams2: Add high water mark for Readable
Also, organize the numeric settings a bit on the ReadableState class
@isaacs isaacs streams2: Set Readable lwm to 0 by default 62dd040
@isaacs isaacs streams2: Only emit 'readable' when needed 286c544
@isaacs isaacs streams2: Writable organization, add 'finishing' flag 0118584
@isaacs isaacs test: Update stream2 transform for corrected behavior c2f62d4
@isaacs isaacs streams2: Do multipipe without always using forEach
The Array.forEach call is too expensive.
@isaacs isaacs streams2: Remove function.bind() usage
It's too slow, unfortunately.
@isaacs isaacs streams2: Get rid of .once() usage in Readable.pipe
Significant performance impact
@isaacs isaacs streams2: Set 'readable' flag on Readable streams 53fa66d
@isaacs isaacs streams2: Refactor out .once() usage from Readable.pipe() 4b4ff2d
@isaacs isaacs streams2: Handle pipeChunkSize properly ac5a185
@isaacs isaacs streams2: Remove pipe if the dest emits error 49ea653
@isaacs isaacs streams2: Unpipe on dest.emit('close') d58f265
@isaacs isaacs zlib: streams2 0e01d63
@isaacs isaacs test: Fix test-repl-autolibs inspect call 79fd962
@isaacs isaacs fs: streams2 44b308b
@isaacs isaacs test: simple/test-file-write-stream needs to use 0 lowWaterMark 70461c3
@isaacs isaacs test: Writable stream end() method doesn't take a callback 3d3a0b3
@isaacs isaacs crypto: Streaming interface for Hash 90de2dd
@isaacs isaacs crypto: Streaming api for Hmac 175f78c
@isaacs isaacs crypto: Streaming interface for cipher/decipher/iv e336134
@isaacs isaacs crypto: Streaming interface for Sign and Verify dd3ebb8
@isaacs isaacs test: Tests for streaming crypto interfaces e0c600e
@isaacs isaacs doc: Crypto streaming interface 4a32d53
@isaacs isaacs streams2: Set readable=false on end 83704f1
@isaacs isaacs streams2: Switch to old-mode immediately, not nextTick
This fixes the CONNECT/Upgrade HTTP functionality, which was not getting
sliced properly, because readable wasn't emitted on this tick.


@isaacs isaacs streams2: pause() should be immediate 99021b7
@isaacs isaacs streams2: NextTick the emit('readable') in resume()
Otherwise resume() will cause data to be emitted before it can be handled.
@isaacs isaacs test: Sync writables may emit finish before callbacks f8bb031
@isaacs isaacs lint fc7d8d5
@isaacs isaacs streams2: Call read(0) on resume()
Otherwise (especially with stdin) you sometimes end up in cases
where the high water mark is zero, and the current buffer is at 0,
and it doesn't need a readable event, so it never calls _read().
@isaacs isaacs streams2: Writable only emit 'finish' once 5760244
@isaacs isaacs benchmark: Add once() function to net-pipe benchmark fixture 7742257
@isaacs isaacs streams2: Support a Readable hwm of 0
Necessary for proper stdin functioning
@isaacs isaacs streams2: Emit pause/resume events 04541cf
@isaacs isaacs streams2: Remove extraneous bufferSize setting 854171d
@isaacs isaacs docs: streams2 20a88fe
@isaacs isaacs child_process: Remove stream.pause/resume calls
Unnecessary in streams2
@isaacs isaacs net: Refactor to use streams2
This is a combination of 6 commits.

* XXX net fixup lcase stream

* net: Refactor to use streams2

    Use 'socket.resume()' in many tests to trigger old-mode behavior.

* net: Call destroy() if shutdown() is not provided

    This is important for TTY wrap streams

* net: Call .end() in socket.destroySoon if necessary

    This makes the http 1.0 keepAlive test pass, also.

* net wtf-ish stuff kinda busted

* net fixup
@isaacs isaacs tty/stdin: Refactor for streams2 bb56dcc
@isaacs isaacs test updates b4df1e6
@isaacs isaacs test: Fix many tests for streams2 net refactor 695abba
@isaacs isaacs http: Refactor for streams2
Because of some of the peculiarities of http, this has a bit of special
magic to handle cases where the IncomingMessage would wait forever in a
paused state.

In the server, if you do not begin consuming the request body by the
time the response emits 'finish', then it will be flushed out.

In the client, if you do not add a 'response' handler onto the request,
then the response stream will be flushed out.
@isaacs isaacs test updates for streams2 19ecc3a
@isaacs isaacs test: Fix many tests for http streams2 refactor 0977638
@isaacs isaacs streams2: Still emit error if there was a write() cb 3751c0f
@isaacs isaacs test: Update simple/test-fs-{write,read}-stream-err for streams2
Streams2 style streams might have already kicked off a read() or write()
before emitting 'data' events.  Make the test less dependent on ordering
of when data events occur.
@isaacs isaacs test: Update message tests for streams2 cd51fa8
@isaacs isaacs Merge branch 'streams2' 01db736

Now this is sexy.

@isaacs There's a long way to go before we can publish this. I benchmarked it on my machine with ab -c 100 -t 100 -k and the difference is massive.

v0.8: ~18000 r/s
master: ~11000 r/s


@piscisaureus We can publish unstable releases with performance regressions. We just can't go to 0.10 until it's back up to par. These problems are solvable.

@bnoordhuis bnoordhuis buffer: allocate memory with mmap()
Work around an issue with the glibc malloc() implementation where memory blocks
are never returned to the operating system when they are allocated with brk()
and have overlapping lifecycles.

Fixes #4283.

This causes a huge performance hit on SmartOS, and doesn't compile on OS X.

The OS X issue is easily worked around: b527e69

But the performance issue is more concerning.


Actually, this causes a performance hit on Ubuntu, it looks like, though less pronounced.

Actually, this causes a performance hit on Ubuntu.

It's actually a little faster for me (with 32 kB buffers) on x86_64 3.7-rc. I posted some numbers here. What does uname -a print?

This causes a huge performance hit on SmartOS

Can you quantify that?

isaacs and others added some commits
@isaacs isaacs test: Fix test-https-localaddress*
Fix #4418
@bnoordhuis bnoordhuis buffer: use MAP_ANON, fix OS X build ddb1560
@indutny indutny Revert "build: enable DEAD_CODE_STRIPPING on OS X"
This reverts commit 02dffb0.
DEAD_CODE_STRIPPING is stripping out CRYPTO_set_add_lock_callback
symbol on which some addons are relying.
@deanm deanm typed arrays: re-export SizeOfArrayElementForType()
Although it is not used externally by node, it is needed by upstream and Plask.

This effectively reverts:

    commit 1444801
    Author: Aaron Jacobs <>
    Date:   Thu Mar 15 13:26:35 2012 +1100

        typed arrays: unexport SizeOfArrayElementForType()

        It isn't used anywhere else, so made it an implementation detail in
@deanm deanm typed arrays: fix missing type in SizeOfArrayElementForType()
When Mikael Bourges-Sevenier added support for Uint8ClampedArray in 67fc1da,
the new type was not added to SizeOfArrayElementForType().
@isaacs isaacs Revert "buffer: allocate memory with mmap()"
Also Revert "buffer: use MAP_ANON, fix OS X build"

This reverts commit ddb1560.
This reverts commit 2433ec8.
@isaacs isaacs net: Handle sync writable streams synchronously
This fixes the case where stderr doesn't flush before the process exits.
@indutny indutny deps: upgrade libuv to b86ed94 ba75452
@bnoordhuis bnoordhuis deps: upgrade libuv to dc559a5 7b2ef2d
@bnoordhuis bnoordhuis node: s/-/_/ in add-on symbol name
Replace dashes with underscores. When loading foo-bar.node, look for
foo_bar_module, not foo-bar_module. The latter is not a legal symbol name.
@bnoordhuis bnoordhuis node: remove idle gc
Remove the idle garbage collector. Its purpose was to run the garbage collector
when the application is idle but it never worked quite right. Many people have
complained over the years that with heaps > 128 MB, a node.js process never
sleeps anymore; instead, it spends nearly 100% of its CPU time trying to
collect garbage.

Back in the old days, idle GC probably was a good idea. But with V8's current
incremental collector, idle gc appears to offer no time or space benefits
whatsoever and indeed seems actively harmful. Remove it.

Fixes #3870.
@isaacs isaacs benchmark: Add http-flamegraph
This is very similar to, but generates a flamegraph
with dtrace, pruning off the single-hit stacks so that we can
more easily see the places where relevant amounts of time are
@tjfontaine tjfontaine test: add TAP output to the test runner 14ed173
@isaacs isaacs test: 2 resume() calls needed to flush streams f3f4e29
@isaacs isaacs test-pummel: Add call validation in net-write-callbacks f63af64
@isaacs isaacs net: Properly read buffer in Socket.bytesWritten cab2264
@isaacs isaacs streams2: Process write buffer in a loop, not recursively
This fixes pummel/test-net-write-callbacks
@alFReD-NSH alFReD-NSH fs: add autoClose=true option to fs.createReadStream dcaebec
@bnoordhuis bnoordhuis Merge remote-tracking branch 'origin/v0.8' 79ae8b7
@bnoordhuis bnoordhuis bench: report stats in benchmark/net-pipe d1556fb
@piscisaureus piscisaureus openssl: make perlasm target pentium or newer for masm outputs
When perlasm generates MASM code it sets the assembler target to 468.
In this mode MASM refuses to assemble a couple of instructions. Bumping
the target to 686 solves this problem.
@piscisaureus piscisaureus openssl: clean up and merge configuration files
This patch brings the openssl library that is built with gyp closer
to what the standard build system produces.

All opensslconf.h versions are now merged into a single file, which
makes it easier for compiled addons to locate this file.
@piscisaureus piscisaureus openssl: revert empty_OPENSSL_cpuid_setup.patch aeae22c
@piscisaureus piscisaureus openssl: disable HT sidechannel attack mitigation
It used to be off before. It's extremely unlikely that such an attack
would be a viable attack against node. And it makes AES much slower.
@piscisaureus piscisaureus openssl: update makefile for asm files to work with openssl 1.0.1 1b5c5b1
@piscisaureus piscisaureus openssl: regenerate asm files for openssl 1.0.1 5edbb53
@piscisaureus piscisaureus openssl: enable optimized asm code on x86 and x64 7475982
@isaacs isaacs benchmark: Improve http-flamegraph 836593d
@isaacs isaacs http: use IncomingMessage._dump() instead of resume() 8624adf
@isaacs isaacs streams: Speed up by doing less work in the state ctors f9caf70
@isaacs isaacs benchmark: Support names in http-flamegraph 79ec9dc
@isaacs isaacs benchmark: Make more useful 825af45
@isaacs isaacs benchmark: Set ephemeral ports properly on sunos ec74555
@isaacs isaacs http: Trivial fix for comments and '' c048c81
@isaacs isaacs lint fb915ed
@isaacs isaacs test: Fix simple/test-http-localaddress 0edd93d
@isaacs isaacs stdio: Do not read from stdout/err
This fixes windows stdio pipes in streams2 land.
@sblom sblom Ease building with VS Express by checking in generated files. 841b7f5
@isaacs isaacs Merge remote-tracking branch 'ry/v0.8' f119eff
@isaacs isaacs doc: Nudge formatting to make json generator happy
Starting a line with `**bold**` text makes it think that it's a link,
and get confused.

This should really be fixed properly in the doc generator, but for now,
it's not a major issue.  It's probably just a matter of updating marked.
@TooTallNate TooTallNate repl: don't touch `require.cache`
Fixes #3226.

Consider a production server that uses a REPL to debug. Creating the instance
would wipe out the global cache of modules, and subsequent "require" calls in
the server would be reloaded from disk. The REPL should observe only, without
altering, its environment.
@isaacs isaacs 2012.12.21, Version 0.9.4 (Unstable)
* streams: Update all streaming interfaces to use new classes (isaacs)

* node: remove idle gc (Ben Noordhuis)

* http: protect against response splitting attacks (Bert Belder)

* fs: Raise error when null bytes detected in paths (isaacs)

* fs: fix 'object is not a function' callback errors (Ben Noordhuis)

* fs: add autoClose=true option to fs.createReadStream (Farid Neshat)

* process: add getgroups(), setgroups(), initgroups() (Ben Noordhuis)

* openssl: optimized asm code on x86 and x64 (Bert Belder)

* crypto: fix leak in GetPeerCertificate (Fedor Indutny)

* add systemtap support (Jan Wynholds)

* windows: add ETW and PerfCounters support (Scott Blomquist)

* windows: fix normalization of UNC paths (Bert Belder)

* crypto: fix ssl error handling (Sergey Kholodilov)

* node: remove eio-emul.h (Ben Noordhuis)

* os: add os.endianness() function (Nathan Rajlich)

* readline: don't emit "line" events with a trailing 'n' char (Nathan Rajlich)

* build: add configure option to generate xcode build files (Timothy J Fontaine)

* build: allow linking against system libuv, cares, http_parser (Stephen Gallagher)

* typed arrays: add slice() support to ArrayBuffer (Anthony Pesch)

* debugger: exit and kill child on SIGTERM or SIGHUP (Fedor Indutny)

* url: url.format escapes delimiters in path and query (J. Lee Coltrane)
@isaacs isaacs Merge branch 'v0.9.4-release' cdcac49
@isaacs isaacs Now working on 0.9.5 70eb227
@mmalecki mmalecki build: allow to specify custom tags
When building custom `node` versions (e.g., floating features/fixes from
different versions) it's often useful to specify a custom tag which
easily identifies build when invoking `node -v`.

Introduce a way to specify this tag in `node_version.h` file or by
running `./configure --tag="<tag>"`. Insert it right after the patch
version (and before `-pre`, if build is not a release).

Closes #4452.
@bnoordhuis bnoordhuis openssl: clean up openssl.gyp
Remove obsolete build configuration that escaped the purge in 7eaea7f.
@bentaber bentaber net: allow socket end before connect
Fix a bug where calling .end() on a socket without calling .connect() first
throws a TypeError:

  TypeError: Cannot read property 'shutdown' of undefined
      at Socket.onSocketFinish (net.js:194:20)
      at Socket.EventEmitter.emit (events.js:91:17)
      at Socket.Writable.end (_stream_writable.js:281:10)
      at Socket.end (net.js:352:31)

Fixes #4463.
@bnoordhuis bnoordhuis test: add regression test for #4463 d2e7ca0
@tricknotes tricknotes util: fix deprecation message in `util.pump` 27a9138
@AndreasMadsen AndreasMadsen stream: fix event handler leak in readstream pipe and unpipe
After a stream was unpiped there would stil be residual event handlers
@AndreasMadsen AndreasMadsen stream: do only fake drain when unpiped stream is the source
If the destination had multiply read streams piped to it,
they would all decrease the awaitDrain state and thereby
start the flow
@AndreasMadsen AndreasMadsen doc: document the finish event
Since the stream implementer is not expected to overwrite
.end() the finish event is necessary in order to know when
no more data can be written
@shigeki shigeki stream2: fix to emit end event on http.ClientResponse 8bf0c15
@tricknotes tricknotes repl: add 'domain' to automatic loading libs
`domain` should be a member of automatic loading libs in `repl`.


@tricknotes tricknotes repl: remove 'repl' from automatic loading libs
In repl, calling `repl` twice shows the following message:
> repl
A different "repl" already exists globally

Does this fix #3012 ?


@kapouer Yes, thanks :)

@isaacs isaacs http: Handle end only when stream is not dumped
This fixes regression introduced in some cases by 8bf0c15

@isaacs Thanks. I should have cared about it.

isaacs and others added some commits
@isaacs isaacs build: Add hyphen to custom build tags
so that ./configure --tag=foo makes a version number like v0.9.5-foo
instead of v0.9.5foo
@tricknotes tricknotes http: remove unused variable
The module variable `END_OF_FILE` was no longer needed from 1d36931.
@tricknotes tricknotes domain: speed up domain.create
Use `` instead of `EventEmitter.apply` because of performance.
@tricknotes tricknotes stream: speed up instantiation of readable stream
- Stream.apply ->
@bentaber bentaber net: socket.readyState corrections
socket.readyState, .readable, and .writable behavior changed as
a result of the new streaming interfaces. Updated to be backwards
compatible with current API and adds regression test.

closes #4461
@luk- luk- Colorize API stabilitity index headers in docs
Noted in @shtylman's #3898, API stability notes are easy to overlook
in the html documentation. This can be especially troublesome if the API
is deprecated. This commit gives visual feedback by adding in a class
to the html docs when they're generated. The API headers with
corresponding colors are also listed in the 'About this Documentation'
page for easy reference.
@bnoordhuis bnoordhuis buffer: speed up base64 encoding by 20%
Remove a lot of branches from the inner loop. Speeds up buf.toString('base64')
by about 20%.


  $ time out/Release/node benchmark/buffer-base64-encode.js
  real    0m6.607s
  user    0m5.508s
  sys     0m1.088s


  $ time out/Release/node benchmark/buffer-base64-encode.js
  real    0m5.520s
  user    0m4.520s
  sys     0m0.992s
@tricknotes tricknotes https: optimize https.createConnection()
Stop using `arguments` for performance and readability.
@bnoordhuis bnoordhuis fs: remove fs.sendfile()
Said function has been broken (and useless) since v0.6.0. Remove it altogether.

Fixes #3854.
@bnoordhuis bnoordhuis fs: make 'end' work with ReadStream without 'start'
Make `fs.createReadStream({ end: 42 })` work.

Before this commit, it worked only when used like this:
`fs.createReadStream({ start: 0, end: 42 })` - only when `start` was specified
by the caller.

Fixes #4423.
@isaacs isaacs domain: Do not use uncaughtException handler
This adds a process._fatalException method which is called into from
C++ in order to either emit the 'uncaughtException' method, or emit
'error' on the active domain.

The 'uncaughtException' event is an implementation detail that it would
be nice to deprecate one day, so exposing it as part of the domain
machinery is not ideal.

Fix #4375
@isaacs isaacs domain: use camelCase instead of snake_case
While it's true that error objects have a history of getting snake_case
properties attached by the host system, it's a point of confusion to
Node users that comes up a lot.  It's still 'experimental', so best to
change this sooner rather than later.
@isaacs isaacs test-message: Add setTimeout and nextTick message tests 1c2910d
@lukebayes lukebayes assert: improve support for new execution contexts
More detailed information in GH-693
@isaacs isaacs http: Replace "in" usage with "=== undefined"
Speeds up http benchmarks.
@isaacs isaacs net: Move createWriteReq to separate function aec2f73
@isaacs isaacs timers: Move list.ontimeout to separate function ba94f9d
@isaacs isaacs http: Separate out the storeHeader closure f423287
@isaacs isaacs net: Don't go through Stream API when ondata is used
This speeds up http_simple by around 6%.
@isaacs isaacs benchmark: Make flamegraphs a bit more useful 7550e31
@isaacs isaacs benchmark: Set port range properly on Linux ecdde7d
@isaacs isaacs node: emit 'exit' when exiting with error
Fix #3555
@isaacs isaacs 2012.12.30, Version 0.9.5 (Unstable)
* assert: improve support for new execution contexts (lukebayes)

* domain: use camelCase instead of snake_case (isaacs)

* domain: Do not use uncaughtException handler (isaacs)

* fs: make 'end' work with ReadStream without 'start' (Ben Noordhuis)

* https: optimize createConnection() (Ryunosuke SATO)

* buffer: speed up base64 encoding by 20% (Ben Noordhuis)

* doc: Colorize API stabilitity index headers in docs (Luke Arduini)

* net: socket.readyState corrections (bentaber)

* http: Performance enhancements for http under streams2 (isaacs)

* stream: fix to emit end event on http.ClientResponse (Shigeki Ohtsu)

* stream: fix event handler leak in readstream pipe and unpipe (Andreas Madsen)

* build: Support ./configure --tag switch (Maciej Małecki)

* repl: don't touch `require.cache` (Nathan Rajlich)

* node: Emit 'exit' event when exiting for an uncaught exception (isaacs)
@isaacs isaacs Merge branch 'v0.9.5-release' 9ff2b0b
@isaacs isaacs Now working on 0.9.6 30bd774

It would be good to a) update the documentation for the 'exit' event, and b) mention this change in the release notes. People now need to to discern between calls to process.exit() and exceptional exits in their exit listeners.

(People shouldn't be executing complicated clean-up logic inside an exit listener, of course, but many do.)

bnoordhuis and others added some commits
@bnoordhuis bnoordhuis dgram: fix double implicit bind error
Calling send() on an unbound socket forces an implicit bind to
a random port.

332fea5 made the 'listening' event asynchronous. Unfortunately,
it also introduced a bug where the implicit bind was tried more
than once if send() was called again before the first bind operation

Address that by keeping track of the bind status and making sure that
bind() is called only once.

Fixes #4499.
@indutny indutny deps: update v8 to 3.15.11 7b4d95a
@indutny indutny bindings: update to new v8 apis
GetPointerFromInternalField() is deprecated now, we should use
@indutny indutny test: make tests work with newer v8 8a96bb4
@bnoordhuis bnoordhuis v8: remove optimization switches
Remove compiler switches from $(TOPLEVEL)/deps/v8/build/common.gypi,
we set them globally in $(TOPLEVEL)/common.gypi.

Commit 7b4d95a introduced the switches again, resulting in V8 getting
built without any optimizations.

This commit is essentially a rehash of commit 4b8629d.
@bnoordhuis bnoordhuis node: remove ev-emul.h
libev has been deprecated since v0.6. Add-on authors have had two major
release cycles to upgrade. Out it goes.
@bnoordhuis bnoordhuis repl: allow overriding builtins
Don't give names of built-in libraries special treatment.
Changes the REPL's behavior from this:

  > var path = 42
  > path
  A different "path" already exists globally

To this:

  > var path = 42
  > path

Fixes #4512.
@bnoordhuis bnoordhuis Merge remote-tracking branch 'origin/v0.8'
@sblom sblom windows: fix perfctr crash on XP and 2003
Some performance counter related functions are not available on Windows
XP and Windows Server 2003, which caused node to call a NULL pointer.

Closes #4462
Closes #4511
@sblom sblom windows: improve Visual Studio Express build support
* Moved generated files to a clearer directory.
* Improved detection logic for ctrpp.exe tool.

Closes #4482
@Niggler Niggler REPL: fix floating point number parsing
In JS, the expression ".1" is a floating point number.  Issue 4268 concerns the
REPL interpreting floating point numbers that lead with a "." as keywords.  The
original bugfix worked for this specific case but not for the general case:

    var x = [

The attached change and test (`.1+.1` should be `.2`) fix the bug.

Closes #4513.
@indutny indutny v8: update to 0054264
@indutny indutny object_wrap: add missing HandleScope
by Sven Panne's suggestion, see [0] for details.

@bnoordhuis bnoordhuis v8: remove optimization switches
Remove compiler switches from $(TOPLEVEL)/deps/v8/build/common.gypi,
we set them globally in $(TOPLEVEL)/common.gypi.

Commit 7b4d95a introduced the switches again, resulting in V8 getting
built without any optimizations.

This commit is essentially a rehash of commit 4b8629d.
@shigeki shigeki fs: pool size coincide with ReadStream bufferSize
pool size of file reading in ReadableStream can be adjustable
with a bufferSize option.
@shigeki shigeki fs: remove unused default option in WriteStream
No bufferSize option is used in stream.Writable and fs.WriteStream.
@bnoordhuis bnoordhuis src: use static_cast where appropriate
Use static_cast instead of reinterpret_cast when casting from void*
to another type.

This is mostly an aesthetic change but may help catch bugs when the
affected code is modified.
@JamesHight JamesHight net: add localAddress and localPort to Socket 3f76419
@bmeck bmeck child_process: make fork() execPath configurable
Allows for arbitrary path to executable spawned using `fork`. This
fixes some issues around running multiple versions of node with workers
and allows arbitrary IPC with compatible executables.

Fixes #3248.
@bnoordhuis bnoordhuis test: disable simple/test-debug-brk-file
This test is timing sensitive and hence quite unreliable with debug
builds. What's worse is that it leaves a stray child process behind
that listens on the default test port and that makes all the tests
that come after it fail with EADDRINUSE errors.
@bnoordhuis bnoordhuis test: put tty in blocking mode after test
Tests can leave the tty in non-blocking mode. If the test runner tries
to print to stdout/stderr after that and the tty buffer is full, it'll
die with a EAGAIN OSError. Ergo, put the tty back in blocking mode
before proceeding.
@bnoordhuis bnoordhuis test: fix simple/test-http-client-timeout-with-data
The test was failing in debug mode because the timeouts were set too
low. Fix that by increasing the timeouts. Admittedly not a great fix.
If this test keeps playing up, it's probably best to remove it.

Fixes #4528.
@deanm deanm node: move symbol caching to Load() 8adebb9
@mmalecki mmalecki child_process: don't `resume()` created socket
Calling `resume()` on a stream switches it to the old mode which causes
piping stdio from a child process to fail.

Fixes joyent/node#4510.
@isaacs isaacs stream: Clean up more effectively in pipe() 3e6f737
@isaacs isaacs child_process: Pull through untouched stdio streams
Otherwise child procs will never emit a 'close' event if you don't
ever consume their streams, because they will never hit the EOF.
@bnoordhuis bnoordhuis src: make node_isolate global
V8 3.15 has new API functions that let you specify the Isolate. V8 and
node.js generally spend 0.5-3.5% of the time in pthread_getspecific(),
looking up the current Isolate. Avoid that overhead by making "our"
isolate global so we can pass it around. The change to the new API is
introduced in follow-up commits.
@bnoordhuis bnoordhuis src: pass node_isolate to String::Empty 412b3ce
@bnoordhuis bnoordhuis src: pass node_isolate to Integer::New 6573fc3
@bnoordhuis bnoordhuis src: pass node_isolate to Local<>::New 01c3d0a
@bnoordhuis bnoordhuis src: pass node_isolate to Null() c7d7ae1
@bnoordhuis bnoordhuis src: pass node_isolate to True() and False() 109f73b
@bnoordhuis bnoordhuis src: pass node_isolate to Undefined() 7788a6b

This should probably be backported to v0.8 branch.


Agree. @bnoordhuis ok?

Sure. Though it's kind of pointless unless people recompile their add-ons.


Ok, landed in 7a2ae4c

isaacs and others added some commits
@isaacs isaacs dtrace: SeqAsciiString was renamed to SeqOneByteString in v8 3b715ed
@indutny indutny dtrace: fix style in ustack helper 13296e4
@indutny indutny dtrace: x64 ustack helper f9afb3f
@isaacs isaacs dtrace: Make D style more D-ish 38df9d5
@isaacs isaacs dtrace: More style
Continuation lines should be indented with 4 spaces, not a tab.
@mharsch mharsch build: fail w/err msg when missing binutils
Building --with-dtrace requires objdump from GNU binutils.
This change inserts a helpful error message if there is a
problem executing objdump.
@shigeki shigeki net: fix bufferSize include writableStream length
socket.bufferSize missed to include the length of internal buffers in
@deanm deanm typed arrays: replace switch with templates
Convert TypedArray's TypeName implementation to template specialization
instead of a switch() statement.
@deanm deanm typed arrays: don't declare as module
TypedArrays is not a module, it is attached to the global object.
Don't register it with Node's module system.
@tfeb tfeb doc: os.cpus() returns times in milliseconds e6acfed
@indutny indutny streams: set listener first, emit 'data' later
When switching into compatibility mode by setting `data` event listener,
`_read()` method will be called immediately. If method implementation
invokes callback in the same tick - all emitted `data` events will be
discarded, because `data` listener wasn't set yet.
@isaacs isaacs stream: Override addListener as well as on
For the compatibility switch.

Huh?! You're doing the same thing few lines below. Or am I missing something?


@isaacs don't forget this.

shigeki and others added some commits
@shigeki shigeki stream: fix typo
Also: Revert "stream: Override addListener as well as on"

This reverts commit 18c9859.
@bnoordhuis bnoordhuis typed arrays: undo local changes
Partially revert 5664dd2, 6573fc3 and 7788a6b to ease landing changes
from upstream.
@deanm deanm typed arrays: swizzle with compiler intrinsics
Implement swizzling with compiler intrinsics and be aware of the native
endianness to correctly swap on big endian machines.

This introduces a template function to swap the bytes of a value,
and macros for the low level swap (taking advantage of gcc and msvc
intrinsics). This produces code like the following (comments are mine):

gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

  movd  %xmm0, %rax         ; fp reg -> gen reg
  bswapq  %rax              ; 64-bit byte swap
  movd  %rax, %xmm0         ; gen reg -> fp reg
  movq  %xmm0, (%r15,%r12)  ; store
@deanm deanm typed arrays: implement load and store swizzling
Implement load and store swizzling operations. This reduces an unneeded
back and forth between types and additionally keeps the value in the
swappable type until it is swapped. This is important for correctness
when dealing with floating point, to avoid the possibility of loading
the bits of a signaling NaN (because it isn't yet swapped) into the FPU.

This additionally produces better code (comments are mine):

gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

  movd  %xmm0, %rax         ; fp reg -> gen reg
  bswapq  %rax              ; 64-bit byte swap
  movq  %rax, (%r15,%r12)   ; store
@bnoordhuis bnoordhuis test: run tests in alphabetical order a6756a2
@isaacs isaacs stream: Add readable.push(chunk) method a993f74
@isaacs isaacs stream: Use push() for readable.wrap() 530585b
@isaacs isaacs stream: Use push() for Transform._output()
This also slightly changes the semantics, in that a 'readable'
event may be triggered by the first write() call, even if a
user has not yet called read().

This happens because the Transform _write() handler is calling
read(0) to start the flow of data.  Technically, the new behavior
is more 'correct', since it is more in line with the semantics
of the 'readable' event in other streams.
@isaacs isaacs net: Use readable.push() instead of private methods 840401c
@isaacs isaacs http: Use stream.push() instead of touching _readableState bc8feb1
@isaacs isaacs http: Don't switch the socket into old-mode 9ece63b

I see the problem, but I'm not sure this is the best solution. Is there a way to do this without leaking implementation information from domain.enter and domain.exit?


It may be possible, but I did implement it in such a way that the current interface is fine. If you don't capture the return value or pass a value to exit, it works the same as it does now


That being said, I'm not sure how you could do this without exposing some additional information, since the only value you have to work with is an object reference which may be duplicated (and which is the point of the commit)

Without a new value, what would exit() use to find the right stack frame?


I didn't notice that the parameter was optional, and given that, I withdraw my objections. Something about the domain stack feels unfinished and flaky to me, even with this change, but this is clearly an improvement.


yangguo-chromium-org and others added some commits
@yangguo-chromium-org yangguo-chromium-org v8: Hardfloat does not imply VFPv3, only VFPv2.
Raspberry Pi is an example.


Review URL:
Patch from Chi-Thanh Christopher Nguyen <>.

git-svn-id: ce2b1a6d-e550-0410-aec6-3dcde31c8c00

This is a backport of v8/v8@44419ad.
@TooTallNate TooTallNate configure: define "arm_fpu" and "arm_neon" for ARM
v8's common.gypi file expects them to be defined now.

Closes #4534.
@AndreasMadsen AndreasMadsen path: fix bugs related to paths with trailing slashes bb1c039
@isaacs isaacs http: Set _dumped=false initially
The better to keep the IncomingMessage class isomorphic and avoid
creating additional hidden classes.

@bnoordhuis negative array index broke the build on solaris... it seems to be pretty unobvious for me what this typedef is here for, can you please shed some light on it?


Correction: negative array size.


Is it some sort of clever pattern matching?


this line ^

bnoordhuis and others added some commits
@bnoordhuis bnoordhuis deps: upgrade libuv to 9aab5d4 31fc52a
@piscisaureus piscisaureus Revert "path: fix bugs related to paths with trailing slashes"
It only does the right thing on unix, and the implementation
isn't great either.

This reverts commit bb1c039.
@indutny indutny typed arrays: fix build on sunos 35a137c
@indutny indutny Revert "typed arrays: fix build on sunos"
This reverts commit 35a137c.
@isaacs isaacs test: child process { stdio:'inherit' } 3383d77
@bnoordhuis bnoordhuis typed arrays: fix sunos signed/unsigned char issue
The int8_t and uint8_t typedefs on sunos/smartos depend on a number of
compiler directives. Avoid ambiguity and specify signed and unsigned
char explicitly.

Fixes the following build error:

  ../src/ In static member function 'static void*
  node::WriteWrap::operator new(size_t)':
  ../src/ warning: no return statement in function
  returning non-void [-Wreturn-type]
  In file included from ../src/
  ../src/v8_typed_array_bswap.h: In function 'T
  v8_typed_array::SwapBytes(T) [with T = signed char]':
  ../src/v8_typed_array_bswap.h:150:23:   instantiated from 'T
  v8_typed_array::LoadAndSwapBytes(void*) [with T = signed char]'
  ../src/   instantiated from 'static
  v8::Handle<v8::Value> {anonymous}::DataView::getGeneric(const
  v8::Arguments&) [with T = signed char]'
  ../src/   instantiated from here
  ../src/v8_typed_array_bswap.h:125:16: error: size of array is
piscisaureus and others added some commits
@piscisaureus piscisaureus path: make basename and extname ignore trailing slashes
Fixes #4536
@isaacs isaacs Merge remote-tracking branch 'ry/v0.8' into master
@isaacs isaacs 2013.01.11, Version 0.9.6 (Unstable)
* V8: update to

* node: remove ev-emul.h (Ben Noordhuis)

* path: make basename and extname ignore trailing slashes (Bert Belder)

* typed arrays: fix sunos signed/unsigned char issue (Ben Noordhuis)

* child_process: Fix {stdio:'inherit'} regression (Ben Noordhuis)

* child_process: Fix pipe() from child stdio streams  (Maciej Małecki)

* child_process: make fork() execPath configurable (Bradley Meck)

* stream: Add readable.push(chunk) method (isaacs)

* dtrace: x64 ustack helper (Fedor Indutny)

* repl: fix floating point number parsing (Nirk Niggler)

* repl: allow overriding builtins (Ben Noordhuis)

* net: add localAddress and localPort to Socket (James Hight)

* fs: make pool size coincide with ReadStream bufferSize (Shigeki Ohtsu)

* typed arrays: implement load and store swizzling (Dean McNamee)

* windows: fix perfctr crash on XP and 2003 (Scott Blomquist)

* dgram: fix double implicit bind error (Ben Noordhuis)
@isaacs isaacs Merge branch 'v0.9.6-release' f228e3c
@isaacs isaacs Now working on 0.9.7 9a4a39f
@indutny indutny deps: update v8 to d22bd9e
@bnoordhuis bnoordhuis v8: remove optimization switches
Remove compiler switches from $(TOPLEVEL)/deps/v8/build/common.gypi,
we set them globally in $(TOPLEVEL)/common.gypi.

Commit 7b4d95a introduced the switches again, resulting in V8 getting
built without any optimizations.

This commit is essentially a rehash of commit 4b8629d.
@sblom sblom windows: add support for '_Total' perf counters 8e311d2
@fb55 fb55 repl: make built-in modules available by default
Closes #3564.
Closes #4578.
@TooTallNate TooTallNate repl: fix lint bac537b
@bnoordhuis bnoordhuis deps: upgrade libuv to 8e3e60f e4f2a14
@yangguo-chromium-org yangguo-chromium-org v8: Hardfloat does not imply VFPv3, only VFPv2.
Raspberry Pi is an example.


Review URL:
Patch from Chi-Thanh Christopher Nguyen <>.

git-svn-id: ce2b1a6d-e550-0410-aec6-3dcde31c8c00

This is a backport of v8/v8@44419ad.
@bnoordhuis bnoordhuis gitignore: ignore perf data files e4598aa
indutny and others added some commits
@indutny indutny tls: allow wildcards in common name
see #4592
@piscisaureus piscisaureus buffer: zero-length buffers shouldn't be slab-backed e501ce4
@isaacs isaacs stream: Do not call endReadable on a non-empty stream
Say that a stream's current read queue has 101 bytes in it, and the
underlying resource has ended (ie, reached EOF).

If you do something like this:; // leave a byte behind; // read(0) for some reason

then the read(0) will get 0 from the howMuchToRead function.  Since the
stream was ended, this was incorrectly treating the 0 as a "there is no
more in the buffer", and emitting 'end' before that last byte was read.

Why have the read(0) in the first place?  We do this in some cases to
trigger the last few bytes of a net socket (such as a child process's
stdio pipes).  This was causing issues when piping a `git archive` job
to a file: the resulting tarball was incomplete, because it occasionally
was not getting the last chunk.

I think adding API for this is not the right approach (and certainly is not allowed in v0.8).

The key is to clear the entire domain stack on caught errors. What is the value of passing a token to enter/exit?

Is there ever a use case in which you'd want to enter the same domain multiple times?

It would be good to start with a failing test, so that the intended functionality can be more clear.

isaacs and others added some commits
@isaacs isaacs streams2: Do not allow hwm < lwm
There was previously an assert() in there, but this part of the code is
so high-volume that the added cost made a measurable dent in http_simple.

Just checking inline is fine, though, and prevents a lot of potential
@indutny indutny tls: follow RFC6125 more stricly
* Allow wildcards only in left-most part of hostname identifier.
* Do not match CN if altnames are present

I will remove the second patch from this branch and move it to a different one, come up with a test/use case, and file separately. Thanks for the feedback, Isaac

EDIT: this is now done, and only the "clear the stack" patch is left on this PR. Let me know if you have further concerns with the fix

bnoordhuis and others added some commits
@bnoordhuis bnoordhuis v8: work around String::WriteAscii segfault
See for details.
Once the patch lands in upstream V8, this commit can be reverted.
@mathiasbynens mathiasbynens punycode: update to v1.2.0
This update adds support for RFC 3490 separators for improved
compatibility with web browsers.
@FZambia FZambia http: fix duplicate var initialization
IncomingMessage function contained duplicate initialization
of this._pendings. Line with one of those expressions has been
@trevnorris trevnorris buffer: floating point read/write improvements
* floating point operations are approx 4x's faster
* Now write quiet NaN's
* all read/write on floating point now done in C, so no more need for
* float values have more accurate min/max value checks
* add additional benchmarks for buffers read/write
* created benchmark/_bench_timer.js which is a simple library that
  can be included into any benchmark and provides an intelligent tracker
  for sync and async tests
* add benchmarks for DataView set methods
* add checks and tests to make sure offset is greater than 0
@trevnorris trevnorris buffer: improve read/write speed with assert
Improved assert check order of execution and added additional checks on
parameters to ensure no bad values make it through (e.g. negative offset
@isaacs isaacs stream: Properly handle large reads from push-streams
Problem 1: If stream.push() triggers a 'readable' event, and the user
calls `read(n)` with some n > the highWaterMark, then the push() will
return false (indicating that they should not push any more), but no
future 'readable' event is coming (because we're above the

Solution: return true from push() when needReadable is set.

Problem 2: A read(n) for n != 0, after the stream had encountered an
EOF, would not trigger the 'end' event if the EOF was pushed in
synchronously by the _read() function.

Solution: Check for ended in and schedule an end event if
the length now equals 0.

Fix #4585
@aeosynth aeosynth assert that require() has a truthy path c93c99c
@deanm deanm TypedArrays: Improve dataview perf without endian param
V8 seems to be particularly slow converting an undefined value to false
in BooleanValue.

Revert this when we upgrade to V8 3.17, or whenever the fix discussed
in lands in V8.
@tricknotes tricknotes repl: fix how to module requiring in code comment
This module requiring style is old.
This API has been changed in Node 0.1.16 726865a.
@isaacs isaacs lint: Prefer double-quotes over single b9ffc53
@fb55 fb55 module: assert that require() is called with a string
as requested in #4577
@isaacs isaacs test: add module-loading test with empty string 47f3fc9
@bnoordhuis bnoordhuis deps: upgrade libuv to 4ba03dd 952e42d
@tricknotes tricknotes doc: modify documentation style about 'Stability: 5'
'Stability: 5' is described as 'Locked' not as 'API Locked'
in other documents.

For example:
- `/doc/api/assert.markdown`
- `/doc/api/util.markdown`

This word was injected in 192192a.
@isaacs isaacs events: Don't crash on events named __proto__
This prefixes all event names internally with 'ev'.
@isaacs isaacs stdio: Set readable/writable flags properly
Set the readable/writable flags properly in net streams that have
a handle passed in (such as TTY streams).

Fix #4606
@isaacs isaacs Revert "events: Don't crash on events named __proto__"
Unfortunately, it's just too slow to do this in events.js.  Users will
just have to live with not having events named __proto__ or toString.

This reverts commit b48e303.
@indutny indutny child_process: do not keep list of sent sockets
Keeping list of all sockets that were sent to child process causes memory
leak and thus unacceptable (see #4587). However `server.close()` should
still work properly.

This commit introduces two options:

* child.send(socket, { track: true }) - will send socket and track its status.
  You should use it when you want `server.connections` to be a reliable
  number, and receive `close` event on sent sockets.
* child.send(socket) - will send socket without tracking it status. This
  performs much better, because of smaller number of RTT between master and

With both of these options `server.close()` will wait for all sent
sockets to get closed.
@isaacs isaacs benchmark: Add resume() in static_http_server ae6f4b3
@indutny indutny Revert "child_process: do not keep list of sent sockets"
This reverts commit db5ee0b.
@indutny indutny child_process: do not keep list of sent sockets
Keeping list of all sockets that were sent to child process causes memory
leak and thus unacceptable (see #4587). However `server.close()` should
still work properly.

This commit introduces two options:

* child.send(socket, { track: true }) - will send socket and track its status.
  You should use it when you want to receive `close` event on sent sockets.
* child.send(socket) - will send socket without tracking it status. This
  performs much better, because of smaller number of RTT between master and

With both of these options `server.close()` will wait for all sent
sockets to get closed.

Please rebase onto master and add a test. (Note that the uncaughtException stuff has been moved to src/node.js)

bnoordhuis and others added some commits
@bnoordhuis bnoordhuis v8: add %p option to --logfile, expands to pid
Useful when you are profiling multiple instances of V8 concurrently.
Submitted upstream:

Refs #4617.
@cxreg cxreg always empty domain stack when handling exceptions
Due to the nature of asyncronous programming, it's impossible to know
what will run on the next tick.  Because of this, it's not correct to
maintain domain stack state between ticks

Since the uncaughtHandler is only invoked after the stack is unwound,
once it exits the tick will end.  The only reasonable thing to do in
that case is to exit *all* domains.

I can't change the base branch on this PR so I'll close and re-submit

@cxreg cxreg closed this

Re-filed as PR #4621


@bnoordhuis I'm working on the project zcbenz/cefode which will integrate node API into normal browser's dedicated web workers, this is similar to node's previous deprecated isolates feature, but it only supports the require function in workers to get around the problems you had met before.

But this project relies on the fact built-in modules' code could work under arbitrary isolate, since you were making them rely on the node_isolate, it would make it more difficult to use node in threads and would force me to do more hacks in node. And in very far future when node needs to pick up the isolates feature, what you had done here would cause some troubles.

So is it possible for you to revert the src: pass node_isolate to xx commits? Though it would lose the performance gain you mentioned in 5d0816b.

I feel your pain but the answer is no. What you could do (and what we will probably do if node.js ever supports isolates again) is to store the node_isolate global in thread-local storage.


Why is this present in master as of two months ago, but not in v0.8.21?

The stable branch only gets bug fixes, new API goes in master.

Got it, thanks.


TypeError: Object [object Object] has no method 'end'
at Object.<anonymous> (/tmp/node/test/simple/test-crypto.js:290:9)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:325:13)


This change means that if you (for example) set a on('connection') event on an http.Server, you can't pipe from the socket that is passed to that event. This breaks, eg, . Was this intentional?

Maybe there should also be a check to see if there are any readable listeners on self, and if so go through the stream API?

@indutny Will your work in #5335 satisfy my concerns from the previous comment?


Yes, but performance suffers after it, I'm working on getting it as fast as it is without it.


child.send(message, [sendHandle], [options])
where is the [options] param?
i can't find it in lib/child_process.js

@xianbei This commit never really made it into a stable branch, it got superseded by something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.