From 55f044f87a79b73a99873f4fd761cd9ff50836d0 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 28 Mar 2013 19:13:02 -0400 Subject: [PATCH] Disable send() method in Q promise for Mozilla Task.jsm compatibility Task.jsm allows not only generators but also iterators to be yielded, using ``typeof yielded == 'Function'`` as the test for an iterator, but since the Q promise includes a send() method, yielding a Q promise instead of a Mozilla promise results in an infinite loop. To fix this, we disable Q's send() method, which is just an outdated synonym for invoke() anyway. This will have to be done every time we update Q until send() is removed, Task.jsm is changed, or we stop using Task.jsm with Q promises. --- resource/q.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/resource/q.js b/resource/q.js index f73a91336..47b3118c2 100644 --- a/resource/q.js +++ b/resource/q.js @@ -602,7 +602,9 @@ array_reduce( "dispatch", "when", "spread", "get", "put", "set", "del", "delete", - "post", "send", "invoke", + // .send() disabled by Zotero for Mozilla Task.jsm compatibility + //"post", "send", "invoke", + "post", "invoke", "keys", "fapply", "fcall", "fbind", "all", "allResolved", @@ -1146,7 +1148,8 @@ var post = Q.post = dispatcher("post"); * @param ...args array of invocation arguments * @return promise for the return value */ -Q.send = send; +// Disabled by Zotero for Mozilla Task.jsm compatibility +//Q.send = send; Q.invoke = send; // synonyms function send(value, name) { var args = array_slice(arguments, 2);