Skip to content

Breaking changes between v5 and v6

Jeremiah Senkpiel edited this page Apr 26, 2016 · 12 revisions

Breaking changes between v5 and v6

When editing this page please be as detailed as possible.

89 commits were tagged semver-major.

Note to readers: # is synonymous with .prototype., and indicates the property is available on instances of that class. Example: Object#toString() is equivalent to Object.prototype.toString().

By Subsystem

buffer

[Docs]

  • Deprecated new Buffer() in favor of a few [newly added Buffer APIs: Buffer.from(), Buffer.alloc() and Buffer.allocUnsafe()](https://nodejs.org/dist/latest-v6.x/docs/api/buffer.html#buffer_buffer_from_buffer_alloc_and_buffer_allocunsafe).
  • Removed the previously deprecated Buffer#write(string, encoding, offset, length).
  • Removed the previously deprecated Buffer#{get|set} methods.
    • Buffer#get(index) is superseded by buffer[index].
    • Buffer#set(index, value) is superseded by buffer[index] = value.
    • Refs: 101bca988c, #4594
  • new Buffer(length, encoding) now throws.
    • The length argument had no effect if a number was passed, and this usage indicates a possible security problem.
    • Refs: 3b27dd5ce1, #4514
  • SlowBuffer has been given a docs deprecation notice in favor of the new Buffer.allocUnsafeSlow().

cluster

[Docs]

  • The Worker#suicide property has been deprecated in favor of the more descriptive Worker#exitedAfterDisconnect.
  • The 'message' event from cluster now calls with 3 arguments, with worker being the first argument.
    • Previously the callback signature was (message, handle), now it is (worker, message, handle).
    • Refs: 66f4586dd0, #5361

console

[Docs]

  • Console#timeEnd(label) now internally cleans up after itself.
    • Previously it left the timer label in the _times map.
    • Refs: a5cce79ec3, #3562
  • Console#timeEnd(label) now only emits a warning if the label does not exist.

crypto

[Docs]

  • Error messages from the C++ code are now better formatted.
  • require('crypto') now throws if node has been built without crypto support.
    • Also happens for require('tls'), and require('https').
    • Refs: f429fe1b88, #5611
  • crypto.Certificate no longer has _handle property.
    • Class methods that previously needed this now call to the c++ binding directly.
    • Refs: a37401e061, #5382
  • The digest parameter for crypto.pbkdf2() is now required.
    • Not using the digest parameter currently prints a deprecation warning
  • The default encoding for all crypto methods is now utf8.
    • Previously, the encoding was binary (node's version of latin1).
    • Refs: b010c87164, #5522
  • FIPS-compliant mode is now off by default even if node is built with FIPS-compliance.
    • Note: Regular node releases are not built with FIPS enabled.
    • Refs: 7c48cb5601, #5181

dgram

[Docs]

  • If there is no error when calling Socket#send(), the callback's error paramenter will now once again be null, rather than 0.

dns

[Docs]

  • dns.resolve() now supports resolving plain DNS PTR records.
    • Previously, calling dns.resolve(hostname, 'PTR', cb) would call dns.reverse() on the hostname. That is no longer the case.
    • The hostname must now be passed as a reverse IN-ADDR domain.
    • Refs: dbdbdd4998, #4921

Before:

dns.resolve('8.8.4.4', 'PTR', (err, result) => {
  if (err) {
    // handle error
  }
  // result => ['google-public-dns-b.google.com']
});

After:

dns.resolve('4.4.8.8-in-addr.arpa', 'PTR', (err, result) => {
  if (err) {
    // handle error
  }
  // result => ['google-public-dns-b.google.com']
});

// one could also simply do
dns.reverse('8.8.4.4', (err, result) => {
  if (err) {
    // handle error
  }
  // result => ['google-public-dns-b.google.com']
});
  • dns.lookupService() now coerces the port parameter to a number.
    • Previously, if port was not a number, a TypeError would be thrown.
    • Now, if the port is outside the range of 0-65535, a TypeError will be thrown.
    • Refs: f3be421c1c, #4883

domains

[Docs]

  • Domains no longer assign their context to other error handling code when there is no domain 'error' event handler.
    • Previously, this was only the case if the 'error' event from the domain was handled.
    • Refs: 90204cc468, #4659

events

[Docs]

  • The internal event handler storage object EventEmitter#_events now inherits from Object.create(null) rather than Object.prototype.
    • This prevents issues with events using otherwise reserved property names such as __proto__.
    • This also means that any properties that modules intentionally add to Object.prototype will not be available on _events.
    • Refs: e38bade828, #6092

freelist

  • The deprecated freelist module has been removed.
    • This module was intended to be internal only and we had no intention of maintaining it beyond our own use.
    • Use-cases for this would be better suited using a user-land module.
    • Refs: b70dc67828, #3738

fs

[Docs]

  • fs.readdir{Sync}() now returns filenames in utf8 by default.
    • The encoding of filenames is now configurable via an options object.
    • Example: fs.readdir(path, { encoding: 'hex' }, callback)
    • Refs: 060e5f0c00, #5616
  • Deprecated re-evaluating the fs source code from user code.
  • Deprecated fs.read()'s legacy (fd, length, position, encoding, callback) call signature.
  • fs.read() with a read length of 0 no longer throws.
  • fs.link{Sync}() now does its call parameter checks in the correct order.
  • fs.realpath{Sync}() now uses uv_fs_realpath() under the hood, rather than using a JavaScript implementation.
    • The cache parameter no longer accepts an object cache, and instead has been superseded by an options parameter.
    • Refs: b488b19eaf, #3594

globals

[Docs]

module

[Docs]

  • The current directory is now prioritized for relative lookups.
    • Previously node_module directories would be prioritized if present.
    • For example, require('./example') would previously require node_modules/example if it existed, rather than ./example.js.
    • Refs: d38503ab01, #5689
  • Symlinks are now preserved when using require()
  • Syntax errors in require()'d files now print with more information.

net

[Docs]

  • Valid port checking is now stricter.
  • net.createServer() now throws if a supplied options argument is not an object.
    • It is still possible to only supply a connectionListener callback.
    • Refs: a78b3344f8, #2904
  • The DNS hints V4MAPPED and ADDRCONFIG DNS are no longer set by default.

path

[Docs]

process

[Docs]

  • Accessing process.EventEmitter now prints a deprecation warning.
  • All previously printed node warnings are now more consistent and only emitted via the default handler for a new process 'warning' event.
    • This include deprecations, which are now classified as DeprecationWarnings.
    • Refs: c6656db352, #4782
  • process.nextTick() now throws if the argument is not a function.

querystring

[Docs]

  • The parsed object returned by querystring.parse() now inherits from Object.create(null) rather than Object.prototype.
    • This prevents issues with querystring properties using otherwise reserved property names such as __proto__.
    • This also means that any properties that modules intentionally add to Object.prototype will not be available on the returned object..
    • Refs: dba245f796, #6055
  • querystring.escape() now uses Object#toString() for objects rather than Object#valueOf().
    • This brings it more in-line with the functionality of encodeURIComponent().
    • 5dafb435d8, #5341

readline

[Docs]

  • Readline history can now be disabled by setting the createInterface() option historySize to 0.
    • Previously, setting to 0 would just use the default of 30 lines.
    • Refs: 0303a2552e, #6352
  • Deprecated the following undocumented readline functions, which are only intended for internal use:
    • isFullWidthCodePoint(), stripVTControlCharacters(), getStringWidth(), emitKeys()
    • Refs: ca2e8b292f, #3862
  • Readline#emitKeypressEvents(stream) now always provides the key info parameter in 'keypress' events to the provided stream.

repl

[Docs]

  • It is now possible to assign a variable to _, which usually holds the result of the last expression within the REPL.
    • Doing this will print a warning and disable the behavior of holding the last expression.
    • Refs: ad8257fa5b, 5535
  • Improvements have been made that decrease the number of errors when REPL completion fails.

stream

[Docs]

timers

[Docs]

tls

[Docs]

tty

[Docs]

url

[Docs]

  • url.resolve() now drops auth information of the host changes.
    • This is a security measure to help ensure authentication credentials are not leaked.
    • Refs: eb4201f07a, #1480

util

[Docs]

vm

[Docs]

  • The vm.Script option displayErrors now attaches the line of code that caused the error to the stack trace.

zlib

[Docs]

  • The 'close' event from zlib instances no longer emits on synchronous calls.
  • Gzip trailing garbage after a gzip stream is no longer discarded and now throws an error instead.
    • Note: Null byte padding is not affected, since it has been pointed out at various occasions that such padding is normal and discarded by gzip(1), too.
    • Refs: 54a5287e3e, #5883

Native Modules (Addons)

  • The module ABI has changed due to a minor addition to module initialization.
    • This only means that native addons will need to be recompiled.
    • Refs: 71470a8e45, #4771
  • The NODE_MODULE_VERSION is now 48.
  • Some previously deprecated internal functions have been removed.

General Node

  • Internal tooling no longer ships in node tarballs, reducing their size by about 10%.

--

--

  • Error messages are now more consistent across all modules.
    • All now start with a capital letter, contain no other regular words with capitals, and do not contain ending periods.
    • Additionally, argument names and other code is now always between double quotations (").
    • In some cases, errors are also now more informative.
    • Refs: 20285ad177, #3374, 53a95a5b12, #5616, 8bb60e3c8d, #5590, ec49fc8229, #5981

--

  • Node.js no longer supports Windows Vista or previous versions, and will refuse to run on those versions of windows.
    • Additionally, the installer will not install on those windows versions.
    • The minimum supported versions of windows are now Windows 7 and Windows Server 2008 R2.
    • Refs: 1cf26c036d, 55db19074d, #5167

--

  • Node.js no longer supports building on OS X versions older than 10.7.

--

  • Installing via Makefile (tools/install.py) no longer attempts to change the target location of node in npm's shebang to the locally built node.
    • Instead, it is kept as #!/usr/bin/env node, which looks for node globally.
    • Refs: 8ffa20c495, #6098

Dependencies

  • Shared c-acres builds are now supported once again.
  • V8 has been upgraded to 5.0.71.32 + floating patches.

Clone this wiki locally