{"action":"created","issue":{"url":"https://api.github.com/repos/joyent/node/issues/25623","labels_url":"https://api.github.com/repos/joyent/node/issues/25623/labels{/name}","comments_url":"https://api.github.com/repos/joyent/node/issues/25623/comments","events_url":"https://api.github.com/repos/joyent/node/issues/25623/events","html_url":"https://github.com/joyent/node/issues/25623","id":92905561,"number":25623,"title":".then(Promise.all) fails","user":{"login":"fschargorosdky","id":8282140,"avatar_url":"https://avatars.githubusercontent.com/u/8282140?v=3","gravatar_id":"","url":"https://api.github.com/users/fschargorosdky","html_url":"https://github.com/fschargorosdky","followers_url":"https://api.github.com/users/fschargorosdky/followers","following_url":"https://api.github.com/users/fschargorosdky/following{/other_user}","gists_url":"https://api.github.com/users/fschargorosdky/gists{/gist_id}","starred_url":"https://api.github.com/users/fschargorosdky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fschargorosdky/subscriptions","organizations_url":"https://api.github.com/users/fschargorosdky/orgs","repos_url":"https://api.github.com/users/fschargorosdky/repos","events_url":"https://api.github.com/users/fschargorosdky/events{/privacy}","received_events_url":"https://api.github.com/users/fschargorosdky/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-03T16:29:41Z","updated_at":"2015-07-03T18:27:42Z","closed_at":null,"body":"I want to chain a promise that resolves to an array to Promise.all.\r\nUsing it inside a function works fine:\r\n```javascript\r\nPromise.resolve([1, 2, 3])\r\n  .then(function (promises) {\r\n     return Promise.all(promises);\r\n   })\r\n  .then(function () {\r\n    console.log('works');\r\n  })\r\n  .catch(function (err) {\r\n    console.log(err.stack);\r\n  });\r\n```\r\nBut if I pass Promise.all as the argument of .then, it breaks:\r\n```javascript\r\nPromise.resolve([1, 2, 3])\r\n  .then(Promise.all)\r\n  .then(function () {\r\n    console.log('works');\r\n  })\r\n  .catch(function (err) {\r\n    console.log(err.stack);\r\n  });\r\n```\r\nResult:\r\n```\r\nTypeError: undefined is not a function\r\n    at defer (native)\r\n    at all (native)\r\n    at runMicrotasksCallback (node.js:337:7)\r\n    at process._tickCallback (node.js:355:11)\r\n    at Function.Module.runMain (module.js:503:11)\r\n    at startup (node.js:129:16)\r\n    at node.js:814:3\r\n```\r\nI tried changing the array to an array of promises but it fails the same way:\r\n```javascript\r\nPromise.resolve([Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)])\r\n  .then(Promise.all)\r\n  .then(function () {\r\n    console.log('works');\r\n  })\r\n  .catch(function (err) {\r\n    console.log(err.stack);\r\n  });\r\n```\r\nDoing it with Bluebird works correctly:\r\n```javascript\r\nvar BPromise = require('bluebird');\r\n\r\nBPromise.resolve([1, 2, 3])\r\n  .then(BPromise.all)\r\n  .then(function () {\r\n    console.log('works');\r\n  })\r\n  .catch(function (err) {\r\n    console.log(err.stack);\r\n  });\r\n```"},"comment":{"url":"https://api.github.com/repos/joyent/node/issues/comments/118405374","html_url":"https://github.com/joyent/node/issues/25623#issuecomment-118405374","issue_url":"https://api.github.com/repos/joyent/node/issues/25623","id":118405374,"user":{"login":"thefourtheye","id":696611,"avatar_url":"https://avatars.githubusercontent.com/u/696611?v=3","gravatar_id":"","url":"https://api.github.com/users/thefourtheye","html_url":"https://github.com/thefourtheye","followers_url":"https://api.github.com/users/thefourtheye/followers","following_url":"https://api.github.com/users/thefourtheye/following{/other_user}","gists_url":"https://api.github.com/users/thefourtheye/gists{/gist_id}","starred_url":"https://api.github.com/users/thefourtheye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thefourtheye/subscriptions","organizations_url":"https://api.github.com/users/thefourtheye/orgs","repos_url":"https://api.github.com/users/thefourtheye/repos","events_url":"https://api.github.com/users/thefourtheye/events{/privacy}","received_events_url":"https://api.github.com/users/thefourtheye/received_events","type":"User","site_admin":false},"created_at":"2015-07-03T18:27:42Z","updated_at":"2015-07-03T18:27:42Z","body":"You need to bind the `all` to the `Promise` object, like this\r\n\r\n    Promise.resolve([1, 2, 3])\r\n    \t.then(Promise.all.bind(Promise))\r\n    \t.then(function() {\r\n    \t    console.log('works');\r\n    \t}).catch(function(err) {\r\n    \t    console.log(err.stack);\r\n    \t});"}}