Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

ReferenceError: setImmediate is not defined #4

gflarity opened this Issue Feb 23, 2014 · 3 comments


None yet
3 participants

Hi, I just tried to use pg-cursor with a simple select:

setImmediate(function() {
ReferenceError: setImmediate is not defined
at Cursor._sendRows (/foo/tools/lib/node_modules/pg-cursor/index.js:51:3)
at Cursor.handlePortalSuspended (/foo/tools/lib/node_modules/pg-cursor/index.js:64:8)
at Client.connect.con.once.con.on.self.constructor.port (/foo/tools/lib/node_modules/pg/lib/client.js:112:24)
at EventEmitter.emit (events.js:96:17)
at Connection.attachListeners (/foo/tools/lib/node_modules/pg/lib/connection.js:97:12)
at Socket.EventEmitter.emit (events.js:96:17)
at TCP.onread (net.js:397:14)

What version of node are you using? Looks like setImmediate was added in v0.10: https://github.com/joyent/node/wiki/Api-changes-between-v0.8-and-v0.10

Ah, yes we're using v0.8 and I guess that stopped being supported. Will need to bite the bullet and upgrade soon. We just haven't hit a compelling reason to do so yet.


brianc commented Feb 26, 2014

You can also do this somewhere in code & it should work....

global.setImmediate = global.setImmediate || process.nextTick.bind(process)

I don't rely on any of the intricacies of setImmediate versus process.nextTick so you're safe to monkey-patch.

@brianc brianc closed this Feb 26, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment