-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
Debt - remove WinJS.Promise#done usage #57695
Comments
The typical pattern seems to be I did a search for
Would it make sense to have the // Print a console message when rejection isn't handled within N seconds. For details:
// see https://nodejs.org/api/process.html#process_event_unhandledrejection
// and https://nodejs.org/api/process.html#process_event_rejectionhandled
const unhandledPromises: Promise<any>[] = [];
process.on('unhandledRejection', (reason: any, promise: Promise<any>) => {
unhandledPromises.push(promise);
setTimeout(() => {
const idx = unhandledPromises.indexOf(promise);
if (idx >= 0) {
unhandledPromises.splice(idx, 1);
console.warn('rejected promise not handled within 1 second');
onUnexpectedError(reason);
}
}, 1000);
});
process.on('rejectionHandled', (promise: Promise<any>) => {
const idx = unhandledPromises.indexOf(promise);
if (idx >= 0) {
unhandledPromises.splice(idx, 1);
}
}); |
Update: looks like we do have a |
Yeah, that's what I have seen. More work but will have the better outcome.
That - we should maybe also have that in the main-process and maybe argument the error with some little extra information, e.g that it was an unhandled rejection |
@jrieken is the logic in the |
Yeah, looks like this became a thing, even in browsers: https://developer.mozilla.org/en-US/docs/Web/Events/unhandledrejection and https://developer.mozilla.org/en-US/docs/Web/Events/rejectionhandled. We just need to make sure to listen to the right listener, window vs process |
One thing to note is that as long as we are not on native promises, removing the error handler will result in many of these:
But I think we should get rid of the vast amount of |
@bpasero I don't agree with removing the usage of The problem is that all of our canceled promises will end up in the global handler, and someone who integrates the editor should not have to add a global handler where they check for the |
@alexandrudima yeah my changes only touch the workbench, I leave editor to you, good point. |
PS: to be fair, we probably have tons of code that goes to the standalone editor where we forget to handle errors in promises (because we have no tooling to tell us otherwise), so I would expect that this already happens today. |
I added a Both |
Yeah, sorry. A little over-eager on my side. I add something back |
done |
done with done 👯 |
We have a winjs promise removal plan #53526 and nuking
done
is part of this effort. The plan is to replace usages ofdone
withthen
. We can discuss automating this, e.g. run rename onWinJS.Promise#done
...Despite the winjs recommendation to use
done
, it should be safe (and without alternatives) to usethen
. We do have the global catch all error handler that makes sure errors don't disappear.The text was updated successfully, but these errors were encountered: