pierregoutheraud / atom-js-console

MIT License
10 stars 0 forks source link

Can't handle Promise and then atom crashed #4

Open ukind opened 6 years ago

ukind commented 6 years ago

Sample code:

const promise = new Promise(function(resol, reject) {
  setTimeout(function() {
    const randomInt = Math.floor(Math.random() * 10);
    resol(randomInt);
  }, 500);
});

promise.then(function(promiseResult) {
  console.log('The result is: ', promiseResult);

  return new Promise(function(resolved, rejected) {
    setTimeout(function() {
      const secondRandomInt = Math.floor(Math.random() * 10);
      resolved(secondRandomInt);
    }, 3000);
  }).then(function(resultFromSecondPomise) {
    console.log('Result from second Promise: ', resultFromSecondPomise);
  });
});