-
Notifications
You must be signed in to change notification settings - Fork 24
Migrating from v0.2 to v0.3
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.
-
Move
process.binding('evals')
torequire('vm')
-
In
v0.2
you might have aborted HTTP client requests withreq.connection.destroy()
. Inv0.4
there is a special method to handle thisreq.abort()
-
headers['set-cookie']
is now an array even if it only contains one element. -
TLS/SSL API has changed completely. In v0.2
setSecure()
was used on TCP connections to upgrade them. In v0.3 there is a dedicatedtls
module. See the documentation. -
Instead of testing exceptions with
if (exception.errno == require('constants').EADDRINUSE)
, the exceptions now have a membercode
which is just the string. So you can now do:if (exception.code == 'EADDRINUSE')
-
sys
module is now theutil
module (soft deprecation) -
querystring.parse()
andquerystring.stringify()
were made simpler. They no longer handle deep objects, for nested support view node-querystring. -
querystring.parse()
withparseQueryString
set totrue
now creates an emptyquery
object if there is no query string. In v0.2.6, no object was created in such a case. -
v0.3.6 introduced a new interface for making outbound http requests:
http.request()
andhttp.get()
. Previously users had to construct ahttp.Client
instance and issueclient.request()
calls. The oldhttp.Client
interface is deprecated. The old interface is still supported.setSecure()
is missing and will not be implemented. Use the new interface for making HTTPS requests. See thehttps
module documentation for the new interface. The old HTTPS implementation was never working properly.
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',
port: 80,
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 torequire('tty')
-
stdio.getColumns()
andstdio.getRows()
are coalesced intotty.getWindowSize(fd)
-
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
-
The internal
node::Buffer
class had dramatic changes early on in the v0.3. Any addons which usednode::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.
It appears that connect-auth (with the GitHub module) is broken in v0.3. example application.
Seem that node-couchdb (https://github.com/felixge/node-couchdb) doesn't work with node 0.4.