title: Promise.All resolve never getting called with forEach
body: <p>Good afternoon,
  I have this code to treat a HTTP request response</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// original code: const data = res.data.data;
  const data_ = {
    success: true,
    data: {
      ocupacao_baixa: { count: [], rows: [] },
      ocupacao_moderada: { count: [], rows: [] },
      ocupacao_elevada: {
        count: [{ date_part: 13, count: "1" }],
        rows: [{ date_part: 13 }],
      },
    },
  };
  const data = data_.data;
  
  let horas = new Array(24).fill([0, 0, 0, 0]);
  console.log("DEBUG:horas0", horas);
  
  let getOcupacaoBaixa = new Promise((resolve, reject) =&gt; {
    data.ocupacao_baixa.count.forEach((element, index, array) =&gt; {
      console.log("DEBUG:element", element);
      console.log("DEBUG:horas1", horas);
      console.log(
        "DEBUG:horas[" + element.date_part + "]",
        horas[element.date_part]
      );
  
      horas[parseInt(element.date_part)][1] = parseInt(element.count);
      if (index === array.length - 1) resolve();
    });
  });
  let getOcupacaoModerada = new Promise((resolve, reject) =&gt; {
    data.ocupacao_moderada.count.forEach((element, index, array) =&gt; {
      console.log("DEBUG:element", element);
      console.log("DEBUG:hora2s", horas);
      console.log(
        "DEBUG:horas[" + element.date_part + "]",
        horas[element.date_part]
      );
      horas[parseInt(element.date_part)][2] = parseInt(element.count);
      if (index === array.length - 1) resolve();
    });
  });
  let getOcupacaoElevada = new Promise((resolve, reject) =&gt; {
    data.ocupacao_elevada.count.forEach((element, index, array) =&gt; {
      console.log("DEBUG:element", element);
      console.log("DEBUG:horas3   ", horas);
      console.log(
        "DEBUG:horas[" + element.date_part + "]",
        horas[element.date_part]
      );
      horas[parseInt(element.date_part)][3] = parseInt(element.count);
      if (index === array.length - 1) resolve();
    });
  });
  Promise.all([getOcupacaoBaixa, getOcupacaoModerada, getOcupacaoElevada]).then(
    () =&gt; {
      console.log("DEBUG:dadosMostrar");
      let dadosMostrar = [...horas];
      dadosMostrar.forEach((a, i, arr) =&gt; {
        let b = [...arr[i]];
        b.shift();
        arr[i] = [i.toString(), ...b];
      });
      this.setState({ dadosMostrar: dadosMostrar });
    }
  );</code></pre>
  </div>
  </div>
  </p>
  <p>I use Promise.all because I want to make sure all the forEach loops complete before <code>dadosMostrar</code> is assigned but the resolve callback never gets called. It is getting valid data like in the example code above (<code>data</code>).</p>
  <p>I don't know where the issue might be, but I've always had this happen with waiting for forEach loops.</p>