notablemind / jupyter-nodejs

A node.js kernel for jupyter/ipython
http://nbviewer.ipython.org/gist/jaredly/404a36306fdee6a1737a
MIT License
682 stars 70 forks source link

Immediately rejected Promise kills the kernel #38

Closed obogobo closed 7 years ago

obogobo commented 7 years ago

Hi there, loving the kernel so far! It works great with Node6 and has made presentations a breeze.

One small snag, despite best efforts catching Promise rejections, the kernel seems to die unless a setTimeout is involved. Examples!

this works:

var getHamburgerMaybe = new Promise((resolve, reject) => {
    setTimeout(() => reject("[OutOfMeatException] Where's the beef?"), 3000);
});

getHamburgerMaybe.catch(error => console.log(error));

this kills the kernel:

const p = new Promise((resolve, reject) => {
    reject();
})
.then(
    () => {
        console.log('Promise fulfilled.');
    },
    () => {
        console.log('Promise rejected');
    }
)

Any thoughts?

jaredly commented 7 years ago

I just upgraded to use vm instead of contextify, and it looks like this is working now?

obogobo commented 7 years ago

Ahh great, it works now! Thanks for looking into this 👍