Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Detect the absence of setImmediate for nodejs-v0.8 and lesser #271

wants to merge 1 commit into from

7 participants

Hugues Malphettes Douglas Christopher Wilson Peter Rust Jim Alateras Mark Essel Grigore Dutcovici Francois BEAUFILS
Hugues Malphettes

And fallback to process.nextTick.

Here is how it fails on cloudfoundry's v0.8.2 without this patch:
       async.setImmediate = setImmediate;
ReferenceError: setImmediate is not defined
   at /var/vcap/data/dea/apps/stoic-0-bda8723f9d67b2926c82dcae327b7902/app/node_modules/async/lib/async.js:90:30
   at Object. (/var/vcap/data/dea/apps/stoic-0-bda8723f9d67b2926c82dcae327b7902/app/node_modules/async/lib/async.js:947:2)
   at Module._compile (module.js:449:26)

Peter Rust


Grigore Dutcovici

+1, Node v.0.8.17

Hugues Malphettes

As a workaround, I use a setImmediate schim:

npm install setimmediate

And before using async:



Hugues Malphettes

An almost equivalent patch is committed for 0.2.7 here: b00f5f4

I am guessing @caolan preferred to look for "typeof setImmediate !== 'undefined' " rather than "typeof setImmediate === 'function' "
in case setImmediate ends up to no be a function.

Anyways all is good in node-0.8 land again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 20, 2013
  1. Hugues Malphettes
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/async.js
7 lib/async.js
@@ -87,7 +87,12 @@
else {
async.nextTick = process.nextTick;
- async.setImmediate = setImmediate;
+ if (typeof setImmediate === 'function') {
+ async.setImmediate = setImmediate;
+ }
+ else {
+ async.setImmediate = async.nextTick;
+ }
async.each = function (arr, iterator, callback) {
Something went wrong with that request. Please try again.