Merge lp:~anybox/openobject-client-web/bad-cherrypy-warning into lp:openobject-client-web

Proposed by Christophe Combelles
Status: Needs review
Proposed branch: lp:~anybox/openobject-client-web/bad-cherrypy-warning
Merge into: lp:openobject-client-web
Diff against target: 86 lines (+20/-9)
3 files modified
addons/openerp/static/javascript/openerp/openerp.base.js (+11/-9)
doc/openerp-web.cfg (+1/-0)
openobject/static/javascript/openobject/openobject.http.js (+8/-0)
To merge this branch: bzr merge lp:~anybox/openobject-client-web/bad-cherrypy-warning
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+80966@code.launchpad.net

Description of the change

Merge related to https://bugs.launchpad.net/openobject-client-web/+bug/705312/

When using cherrypy 3.1 and a reverse proxy, we get 408 and 502 errors very often, unless disabling keepalive in the apache config, or raising the default socket_timeout in cherrypy. This is a bug in cherrypy as documented in the bug report, which should be solved in cherrypy 3.1.3.

In the meantime, when this problem occurs, ajax requests fail silently, thus leading to bizarre behaviours:
- missing menuitems
- ir.ui.menu view opening instead of the wanted view.

I have :

1) added an ajaxError handler to catch these errors and display a jquery fancybox with the error code.
2) raised the socket_timeout to 60s in the default config

I've used jQuery to send the ajaxError signal because Mochikit doesn't want to sent it.

To post a comment you must log in.

Unmerged revisions

4725. By Christophe Combelles

[FIX] Don't fail silently if an ajax request fails. It leads to un predictable
behaviour (missing menuitems, wrong view opened). Display an error popup
instead. This happens very often with cherrypy 3.1 and a reverse proxy. It will
help people diagnosing https://bugs.launchpad.net/bugs/705312 more quickly
The related problem should disappear with cherrypy >= 3.1.3

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/openerp/static/javascript/openerp/openerp.base.js'
2--- addons/openerp/static/javascript/openerp/openerp.base.js 2011-08-11 06:14:03 +0000
3+++ addons/openerp/static/javascript/openerp/openerp.base.js 2011-11-02 00:19:26 +0000
4@@ -52,11 +52,14 @@
5 overlayOpacity: 0.7,
6 scrolling: 'no'
7 };
8- if(xhr.getResponseHeader('X-Maintenance-Error')) {
9+ if(xhr.getResponseHeader && xhr.getResponseHeader('X-Maintenance-Error')) {
10 options['autoDimensions'] = false;
11 options['scrolling'] = 'auto';
12+ msg = xhr.responseText;
13+ } else if (xhr.message && xhr.number) {
14+ msg = 'Unknown error ' + xhr.number + ': ' + xhr.message;
15 }
16- jQuery.fancybox(xhr.responseText, options);
17+ jQuery.fancybox(msg, options);
18 }
19
20 /**
21@@ -69,15 +72,11 @@
22 function loadingError(url) {
23 return function (xhr) {
24 if(url) { $.hash(url); }
25- switch (xhr.status) {
26- case 500:
27- displayErrorOverlay(xhr);
28- break;
29- case 401: // Redirect to login, probably
30+ if (xhr.status == 401) { // Redirect to login, probably
31 window.location.assign(
32 xhr.getResponseHeader('Location'));
33- break;
34- default:
35+ } else {
36+ displayErrorOverlay(xhr);
37 if(window.console) {
38 console.warn("Failed to load ", xhr.url, ":", xhr.status, xhr.statusText);
39 }
40@@ -376,5 +375,8 @@
41 if(!concurrencyInfo) return;
42 updateConcurrencyInfo(jQuery.parseJSON(concurrencyInfo));
43
44+ },
45+ ajaxError: function (e, xhr) {
46+ loadingError(e.currentTarget.URL)(xhr)
47 }
48 });
49
50=== modified file 'doc/openerp-web.cfg'
51--- doc/openerp-web.cfg 2011-06-22 09:35:20 +0000
52+++ doc/openerp-web.cfg 2011-11-02 00:19:26 +0000
53@@ -4,6 +4,7 @@
54 # Some server parameters that you may want to tweak
55 server.socket_host = "0.0.0.0"
56 server.socket_port = 8080
57+server.socket_timeout = 60
58
59 # Sets the number of threads the server uses
60 server.thread_pool = 10
61
62=== modified file 'openobject/static/javascript/openobject/openobject.http.js'
63--- openobject/static/javascript/openobject/openobject.http.js 2011-07-08 10:54:52 +0000
64+++ openobject/static/javascript/openobject/openobject.http.js 2011-11-02 00:19:26 +0000
65@@ -37,6 +37,10 @@
66
67 return req.addBoth(function(xmlHttp){
68 openobject.http.AJAX_COUNT -= 1;
69+ if (xmlHttp.status === undefined) {
70+ // Use jquery, as Mochikit signal ajaxError doesn't work
71+ $.event.trigger("ajaxError", xmlHttp);
72+ }
73 if (openobject.http.AJAX_COUNT == 0) {
74 MochiKit.Signal.signal(window, "ajaxStop");
75 }
76@@ -69,6 +73,10 @@
77
78 return req.addBoth(function(xmlHttp){
79 openobject.http.AJAX_COUNT -= 1;
80+ if (xmlHttp.status === undefined) {
81+ // Use jquery, as Mochikit signal ajaxError doesn't work
82+ $.event.trigger("ajaxError", xmlHttp);
83+ }
84 if (openobject.http.AJAX_COUNT == 0) {
85 MochiKit.Signal.signal(window, "ajaxStop");
86 }