Welcome to this week’s wrap up of the week in Node and libuv covering August 14 through August 27. The purpose of this blog is to recap a subset of the non-documentation related commits to Node.js, plus give a little color and commentary to the ongoing development of Node.
Node v0.10 branch highlights
v0.10.17 has been released
Read the official release notes here.
npm has been upgraded to 1.3.8
http: Handle hex/base64 encodings properly
Isaac fixed sending hex and base64 encoded strings with http.ServerResponse#write() in 255650f. The commit log mentions it’s a back-port from the master branch, but points to the wrong commit, the correct one is ce3d184. Non-bug report fix on this one. It was found while going over the http code.
crypto: fix memory leak in randomBytes() error path
Ben fixed a memory leak in the error path of crypto.randomBytes() in f55aca6. No bug report either, found while going over the crypto code.
readline: pause stdin before turning off terminal raw mode
dgram: fix assertion on bad send() arguments
Ben fixed a C++ assert in 0c2960e that got triggered when you passed bad arguments to dgram.Socket#send(). This commit introduces a small change in behavior: before, negative port numbers were silently accepted, but ignored (meaning datagrams were sent to a random port). Now they are rejected with an exception.
stream: Throw on ‘error’ if listeners removed
Isaac fixed an edge case where streams sometimes silently “swallowed” the ‘error’ event 5458079. The commit log has an example.
fs: use correct self reference for autoClose test
tls: fix assertion when ssl is destroyed at read
deps: upgrade http_parser to 303c4e4
Ben upgraded the bundled http_parser library in 8d42c63. The single change is that invalid request methods are now rejected. Before, some were accidentally let through (i.e. GEM was interpreted as GET – pretty trivial but the Internet rabble was up in arms about it.) The initial patch by Chris Dickinson, was fortified by Ben some more in
303c4e4. That probably concludes this year’s changelog for http_parser.
You can view the complete Nodev0.10 commit history on GitHub.
Node master branch highlights
v0.11.6 is out
Read the official release notes here.
dgram: don’t call into js when send cb is omitted
Ben sped up dgram.Socket#send() a little in 1449739 by not calling into JS land when the user hasn’t provide a callback.
build: don’t auto-destroy existing configuration
Ben removed a “feature” from the Makefile in c75251c where it would blindly re-run configure when the configure script had been touched, effectively destroying the current configuration. This particular “feature” had Ben cursing one time too many…
build: make ninja build respect V=
build: disable SSLv2 by default
SSLv2 is now disabled by default (commit 39aa894.) In the deeply unlikely event that you need v2 support, you can enable it again with the –with-sslv2 configure switch.
crypto: add TLS 1.1 and 1.2 to secureProtocol list
tls: handle errors on socket before releasing it
Fedor fixed how the tls module deals with TCP-level socket errors in c50750e. If you got ECONNRESET errors that were impossible to catch – that should be fixed now.
doc: http rawHeaders/rawTrailers
http: Add write()/end() callbacks
http.ServerResponse#write() and end() take (optional) callbacks as of da93d6a.
http: Consistent ‘finish’ event semantics
Isaac changed the semantics of the ‘finish’ event on http streams in 7c9b607, it’s now more like the ‘finish’ event with regular streams. Not sure if that affects many people but if does, consider this a heads up.
http: Prefer ‘binary’ over ‘ascii’
HTTP headers as of 1f9f863 are now encoded from string to buffer with the ‘binary’ encoding rather than ‘ascii’. If you relied on Node.js to strip the high bits off your HTTP headers, then now would be a good time to update your code.
tls, crypto: deduplicate code
Fedor removed a lot of duplicated code in the crypto and tls modules in b9a0eb0 (mostly because Ben kept yelling at him to fix it. We are talking about ~1,000 lines of duplicated code here.) Fixes #6024.
http: removed headers stay removed
events: have events module exports EventEmitter
net: family option in net.connect
Vsevolod Strukchinsky added a ‘family’ option to net.connect() in edd2fcc. Node prefers IPv4 over IPv6 when resolving hostnames, the family flag lets you override that. Some follow-up work to make it work for http.request() etc. is expected.
vm, core, module: re-do vm to fix known issues
util: pass opts to custom inspect functions
Commit 546ae2e by TJ Fontaine makes it so that the optional options object (+3 advanced alliteration application) to util.inspect() now gets passed on to custom .inspect() methods. Fixes #5822 and #6098.
buffer: fix regression in Buffer(buf) constructor
Ben fixed a regression in the Buffer(buf) constructor (the constructor that makes a copy of an existing buffer) in bc28acd. It copied from the new to the old buffer instead of the other way around. As you can imagine, hilarity often ensued!
domain: move error handling directly into instance
Error handling is pluggable as of 467e00e (by Trevor Norris.) What this effectively means is that domains error handling is now configurable by user-land modules, meaning they can set their own error handler. This was requested by New Relic and many others.
src: remove –max-stack-size option
Ben removed the –max-stack-size option in 3a87b31. It was duplicating the functionality of V8’s built-in –stack-size option so no point in keeping it around.
fs: Expose birthtime on stat objects
The st_birthtime field from struct stat is exposed through the fs.Stat object as of 645418e. It’s the creation time of a file. (“Isn’t that the ctime field?” Nope, ctime stands for _change_ time.) It’s only set on platforms that support it natively, currently OS X and the BSDs. Windows and Solaris may follow. Linux doesn’t really have a concept of creation times.
domains: deprecate domain.dispose().
As of d86814a, domain.dispose() is officially deprecated.
You can view the complete Node master commit history on GitHub.
libuv v0.10 branch highlights
unix: retry waitpid() on EINTR
Ben fixed a (probably hypothetical) bug in b2ac4d3 where EINTR wasn’t handled correctly when calling waitpid(). Ben says ‘hypothetical’ because no major platform raises EINTR when the WNOHANG flag is set.
darwin: create fsevents thread on demand
The FSEvents watchdog thread (the thing that watches for file notifications when you call fs.watch() in node on OS X) is now created on-demand rather than at start-up. Commit 9bae606 by yours truly.
fsevents: FSEvents is most likely not thread-safe
Fedor fixed a thread-safety issue in same-said FSEvents code in ea4cb77 and worked around a resource limit issue in 684e212. Fixes joyent/node#5463. If you get “FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)” error messages a lot when watching files, you will want to upgrade to the upcoming Node.js v0.10.18.
windows: make uv_fs_chmod() report errors correctly
You can view the complete libuv v0.10 commit history on GitHub.
libuv master branch highlights
build: disable parallel automake tests
Ben disabled automake’s parallel test runner feature in 35ea88c, added a version check in a97685e, fixed the version check in e4c1483 and fixed it AGAIN in acf1310. Ben would like to thank automake maintainers, for making complicated what should be easy! The motivation for disabling it is that the parallel test runner tends to hide the output until the test has completed – which is supremely annoying because it means you don’t see anything until libuv’s own test runner has completed (which takes minutes.)
build: fix string comparisons in autogen.sh
Ben fixed a bug in the autogen.sh script in 0e4fa70. If your shell complained about an invalid statement, please upgrade. (Libuv, not your shell.)
unix, windows: allow NULL async callback
It’s now possible to pass NULL as the callback to uv_async_send(). Commit 1510ce8. Motivation: for when you want to wake up the event loop in another thread but don’t care about getting notified of that.
darwin: reduce fsevents thread stack size
The FSEvents watchdog thread now uses < 32 kB stack. Saves a few megabytes of address space on 32 bits machines. (On 64 bits machines too, of course, but it’s less pressing there.) Commit c82e703. This should make the Rust people happy.
windows: omit stdint.h, fix msvc 2008 build error
Ben fixed the MSVC 2008 build in 8531046. Apparently people still use that 🙂
windows: make uv_spawn() failure more predictable
uv_spawn() on Windows now behaves more like its Unix counterpart under error conditions. That is, it returns mostly the same errors in mostly the same way. Commit ed82eae by Bert.
process: make the ‘status’ parameter for exit_cb an int64_t
The ‘status’ argument to uv_spawn()’s exit_cb argument is an int64_t rather than an int as of commit 66ae0ff (once again by Bert.) It allows Windows-specific exit codes to get through unmolested.
linux: fix setsockopt(SO_REUSEPORT) error handling
Ben fixed setsockopt(SO_REUSEPORT) error handling on Linux in 17452cd, then decided against it and removed that option altogether (on Linux) in 9d60f1e. The rationale for fixing it is that only recent (>= 3.9) kernels support the socket option. When you compiled libuv against 3.9 kernel headers but ran it on a 3.8 or older kernel, it would panic because the system call failed unexpectedly. Easy to fix, of course. After sleeping on it for a night, Ben came to the conclusion that the SO_REUSEPORT behavior is too different from what older kernels or other platforms do, so he backed it out altogether. The commit log goes into more detail.
windows: reimplement uv_fs_stat using NT syscalls
uv_fs_stat() on Windows is now implemented with native NT system calls rather than the CRT wrapper. That means that the st_blocks, st_blksize, st_ctime, st_dev and st_ino fields now have meaningful and/or correct values. Commit 20a8e58 by Bert.
build: make autotools build system work with mingw
build: remove mingw makefile
unix, windows: add thread-local storage API
Ben added a thread-local storage API in 5d2434b. If you’re familiar with pthread_getspecific() and friends, you’ll feel right at home.
windows: tweak Makefile.mingw for easier usage
windows: make it possible to use NtQueryVolumeInformationFile
build: remove _GNU_SOURCE macro definition
Not sure if anyone cares but it’s no longer required for projects
that include uv.h to compile with -D_GNU_SOURCE on Linux. (No longer
required, it’s still possible and allowed, of course.)
You can view the complete libuv master commit history on GitHub.
- What’s in the upcoming Node v0.12 release? Six new features, plus new and breaking APIs.
- Ready to develop APIs in Node.js and get them connected to your data? Check out the Node.js LoopBack framework. We’ve made it easy to get started either locally or on your favorite cloud, with a simple npm install.
- Need for Node? Learn more about both the private and open options StrongLoop offers.