Skip to content

Commit

Permalink
[FIX] web: get_file and CPU time exceeded
Browse files Browse the repository at this point in the history
- Create a binary field which takes some time for computation. For
example:
```
ding_dong = fields.Binary(compute='_compute_ding_dong')

def _compute_ding_dong(self):
    if not self.env.context.get('bin_size'):
        while True:
            3*3
    for x in self:
        x.ding_dong = x.product_id.image_medium
```
- Run the server with a limited CPU time, for example:
  `--workers=2 --limit-time-cpu=10`
- Download the file

A JS traceback occurs, without any information about the real crash.

The error management is simply not working: `JSON.parse` is called on a
string which is not JSON-parseable.

opw-1838832
  • Loading branch information
nim-odoo committed Apr 26, 2018
1 parent da27836 commit 08b98b2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions addons/web/static/src/js/framework/ajax.js
Expand Up @@ -232,8 +232,12 @@ function get_file(options) {
if (options.error) {
var body = this.contentDocument.body;
var nodes = body.children.length === 0 ? body.childNodes : body.children;
var node = nodes[1] || nodes[0];
options.error(JSON.parse(node.textContent));
options.error({
message: nodes.length > 1 ? nodes[1].textContent : '',
data: {
title: nodes.length > 0 ? nodes[0].textContent : '',
},
});
}
} finally {
complete();
Expand Down

0 comments on commit 08b98b2

Please sign in to comment.