Created
August 13, 2012 17:04
-
-
Save briancavalier/3342531 to your computer and use it in GitHub Desktop.
Q + when.js infinite loop, take 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `npm install q when` | |
// `node test.js` | |
// watch CPU and memory using top | |
var q, when, d; | |
q = require('./node_modules/q'); | |
when = require('./node_modules/when'); | |
// Using either gives the same behavior in all cases I've tried | |
d = q.defer(); | |
//d = when.defer(); | |
// It seems like the next two lines should produce equivalent results, | |
// but they don't. Using q.when() causes an infinite loop, but using | |
// d.promise.promiseSend() works. | |
// Causes infinite loop | |
q.when(d.promise, when.resolve); | |
// Works correctly | |
//d.promise.promiseSend('when', when.resolve); | |
d.resolve(1).then(console.log, console.error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment