Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Migrating from v0.2 to v0.3

ry edited this page · 34 revisions
Clone this wiki locally

Many people are running code on the stable branch v0.2. Soon the unstable branch, v0.3, will become stable. You can help the community by documenting what API changes were made between the two.

JavaScript API

  • sys module is now the util module (soft deprecation)

  • querystring.parse() and querystring.stringify() were made simpler. They no longer handle deep objects.

  • ** v0.3.6 introduced a new interface for making outbound http requests: http.request() and http.get(). Previously users had to construct a http.Client instance and issue client.request() calls. The old http.Client interface should be considered deprecated. That said, there is a legacy interface for http.Client accessible which runs on top of http.request() - you may find inconsistencies between v0.3.6+ http.Client and the http.Client before v0.3.6. These inconsistencies are considered bugs and should be reported.** ** - v0.3.7 resolved many of these bugs.** ** - setSecure() is missing and will not be implemented. Use the new interface for making HTTPS requests. See the https module documentation for the new interface.**

The old http client API:

var http = require('http');
var google = http.createClient(80, 'www.google.com');
var request = google.request('GET', '/',
  {'host': 'www.google.com'});
request.end();
request.on('response', function (response) {
  console.log('STATUS: ' + response.statusCode);
  console.log('HEADERS: ' + JSON.stringify(response.headers));
  response.setEncoding('utf8');
  response.on('data', function (chunk) {
    console.log('BODY: ' + chunk);
  });
});

The new http client API:

var options = {
  host: 'www.google.com',
  path: '/',
};
http.get(options, function(response) {
  console.log('STATUS: ' + response.statusCode);
  console.log('HEADERS: ' + JSON.stringify(response.headers));
  response.setEncoding('utf8');
  response.on('data', function (chunk) {
    console.log('BODY: ' + chunk);
  });
});
  • The internal process.binding('stdio') module got exposed and renamed to require('tty')

  • readline.createInterface now takes three arguments, an input stream, an output stream, and a completion callback. Previously only a output stream was provided.

  • require() now calls realpath on modules. That means if the module is a symlink relative requires will be relative to where the actual file is.

  • NEW: require.resolve

  • NEW: path.resolve

  • REMOVED: path.split, path.normalizeArray

C++ API

  • The internal node::Buffer class had dramatic changes early on in the v0.3. Any addons which used node::Buffer will require heavy rewrite. You might find this and this helpful. Also see buffer.h

  • The binary interface has changed between v0.2 and v0.3. You must recompile all addons. v0.4 will introduce new ABI stability, until then expect to recompile all addons every time you upgrade Node on the v0.3 branch.

Broken Modules

It appears that connect-auth (with the GitHub module) is broken in v0.3. example application.

Something went wrong with that request. Please try again.