Wednesday, January 26, 2022
1 change · master
Resolved issues and error corrections
Fixes an issue where saving website or email editor content could hang if background checks were still running while editor elements were being closed. This helps ensure edits are saved reliably, reducing the risk of users being blocked during content updates.
Original PR description
[FIX] web_editor: resolve ajax request of cleanForSave Upon save in website or in mass_mailing, if a `cleanForSave` of a `SnippetEditor` or a `SnippetOption` wait for the end of an `this._rpc()`…
[FIX] web_editor: resolve ajax request of cleanForSave
Upon save in website or in mass_mailing, if a `cleanForSave` of a
`SnippetEditor` or a `SnippetOption` wait for the end of an
`this._rpc()` request AND the `SnippetEditor` or the `SnippetEditor`
of the `SnippetOption` has a `SnippetEditor` ancestor, the
`cleanForSave` will never resolve.
Here is the scenario:
- **SnippetEditor B** has **SnippetEditor A** as its odoo widget parent
In `SnippetMenu` `_destroyEditors`:
- **SnippetEditor A** and **all its SnippetOption** call `cleanForSave`.
- **SnippetEditor B** and **all its SnippetOption** call `cleanForSave`.
One of the promise of **SnippetEditor B** includes the result of
`rpc()` in `ajax_service.js`.
- **SnippetEditor A** and **all its SnippetOption**
`cleanForSave promises` resolve (but not **SnippetEditor B**).
- **SnippetEditor A** get's destroyed (`snippetEditor.destroy()`). As
**SnippetEditor B** is a `Widget` child of **SnippetEditor A**:
- **SnippetEditor B** get's destroyed (here is where the problem start).
... in the mean time ...
The ajax request of a promise of **SnippetEditor B** ends. The promise
of the `rpc()` will never finish because **SnippetEditor B** is
destroyed and the condition in `rpc()` is:
```js
if (!target.isDestroyed()) {
resolve(result);
}
```
Because the promise will never finish for `_destroyEditors`, the save
action will never fully complete.
Task-2742008