Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some errors are not correctly reported during promises #87

Closed
didattica-forever opened this issue Aug 2, 2021 · 1 comment
Closed

Comments

@didattica-forever
Copy link

I'm quite new to quickjs, while testing (QuickJS version 2021-03-27) I took the following piece of code from MDN
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises

new Promise((resolve, reject) => {
    console.log('Initial');
    resolve();
})
.then(() => {
    throw new Error('Something failed');
    console.log('Do this');
})
.catch(() => {
    console.error('Do that');
})
.then(() => {
    console.log('Do this, no matter what happened before');
});

the only output I got was
Initial
it did took me sometime to discover that the statement
console.error('Do that');
was the origin because of no support, but qjs did not raise any error.

if console.error is used in the main script qjs correctly stops at
TypeError: not a function
at (promises.js:43)

The same happens with "use strict"
and a variable is set without declaration in the promise.

My feeling is that the error is caught but for some reason qjs is not able to abort nor to signal.

thank you beforehand.

Paolo

@fstirlitz
Copy link
Contributor

Use the --unhandled-rejection option. Note there are false positives possible, e.g.

new Promise((accept, reject) => reject('ERROR')).catch(console.log)

will show a warning about a possibly unhandled rejection, since the rejection happens before the handler is attached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants