odoo/odoo#238232

Created by fw-bot
Closed
label
odoo-dev:19.0-saas-18.3-rejected-persistent-cache-lul-481331-fw
head
c5ab104690a59115cfc42a3006b8e5c0a28158de
odoo/odoo
saas-18.3 #237984
saas-18.4 #238185
19.0 #238232

[FIX] web: cache rejected promises

Let's say we trigger two times a RPC that fails.

The first time, the cache is empty and we make the RPC. The ram cache is filled with prom.

The second time, we get prom from the ram cache.

When the RPC actually finishes, we end up in

.catch((error) => {
    this.ramCache.delete(table, key);
    def.reject(error);
});

=> the RPC failure is catched, which means prom itself is not rejected. Instead, it resolves with the result of .catch(...), which is undefined

Here is a simplified toy example:

const prom = Promise.resolve(
    Promise.reject(new Error("fetch failed")).catch(() => {})
);

In this example, prom is successful and the result is undefined

"

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #238185
Forward-Port-Of: #237984