Skip to content

Promise.all(iterable) doesn't work with Sets / Iterables #1348

Closed

Description

@buschtoens

As per the docs, Promise.all(iterable) should work with all kinds of Iterables and not only Arrays. This simple test shows the problem.

var util = require("util")

function inspect() {
  console.log(util.inspect(arguments));
}

console.log("With a Set: (fails)")
var set = new Set([true, true]);
Promise.all(set).then(inspect, inspect);

console.log("With an Array: (works)")
var arr = [true, true];
Promise.all(arr).then(inspect, inspect);

To make Promise.all(iterable) work with a Set, the Set would firstly need to be converted into a regular Array.

console.log("With conversion: (works)")
var set = new Set([true, true]);
var arr = [];

for (let item of set)
  arr.push(item);

Promise.all(arr).then(inspect, inspect);

Activity

  1. changed the title [-]Promise.all(iterable) doesn't work with Sets / Iteratables[/-] [+]Promise.all(iterable) doesn't work with Sets / Iterables[/+] on Apr 5, 2015
  2. zloirock commented on Apr 5, 2015

    @zloirock

    V8 not support it yet, in Chrome too. I fixed v8 Promise.all and Promise.race in core-js.

  3. petkaantonov commented on Apr 5, 2015

    @petkaantonov
    Contributor

    The issue is fixed in dev V8/chrome canary. Io.js uses stable V8 releases (4.1.x), so when Chrome 43 becomes stable it will work in io.js too.

    Closing because this is not a io.js bug

  4. added
    v8 engineIssues and PRs related to the V8 dependency.
    on Apr 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions