Skip to content
Snippets Groups Projects
Commit b58c649d authored by Alexandre Kühn's avatar Alexandre Kühn
Browse files

[FIX] web:tests: remove promise constructor antipattern

Revision on https://github.com/odoo/odoo/commit/141b34f152f36d970d4ff78abe53f563555a8e69

Having async/await as a new promise constructor is an antipattern.

The reason is that it may lead to unnoticed errors: if an inner
promise is rejected, it won't propagate the error to another promise
that will handle the error. As a result, this error becomes unnoticed
and the initial promise is pending indefinitely, which also may lead
to more bugs [1].

[1] https://stackoverflow.com/a/25569299

Closes #43072
parent a1ea321f
Branches
Tags
No related merge requests found
......@@ -20,9 +20,9 @@ var concurrency = require('web.concurrency');
*
* @returns {Promise}
*/
function returnAfterNextAnimationFrame() {
return new Promise(async resolve => {
await concurrency.delay(0);
async function returnAfterNextAnimationFrame() {
await concurrency.delay(0);
await new Promise(resolve => {
window.requestAnimationFrame(resolve);
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment