-
20 Nov 2012 8:29 AM #1
time out Ext.Ajax.Request mistakenly process as valid in Chrome
time out Ext.Ajax.Request mistakenly process as valid in Chrome
I'm using ExtJS 4.1 and I'm getting an uncaught exception in Google Chrome when a timeout occurs.
Code:Ext.Ajax.timeout = 10000; // 10 seconds Ext.Ajax.method = "GET"; Ext.Ajax.request({ url:'rest/dataloggerset.json', params:{ sessionGuid:Ext.getStore("User").getAt(0).get("sessionGuid"), loggerId:this.availableLogFiles.loggerId, logSet:this.currentLog }, success:this.processReceivedLogData, failure:this.failureDuringResourceLoad, scope:this });
The requests ends in a timeout and the so far received data is tried to be parsed in an object. So the uncaught exception that I'm seeing in the developer console looks like :
Uncaught Error: INVALID_STATE_ERR: DOM Exception 11 Connection.js:914 Ext.define.createResponse Connection.js:914 Ext.define.onComplete Connection.js:859 Ext.define.abort Connection.js:767 request.timeout
This issue doesn't come up in FF. Due to the uncaught exception, my method failureDuringResourceLoad is not called.
After some research I've found that the xhr.abort() behaviour differs in Chrome and FF. In Chrome the xhr.status remains unchanged 200, whereas the status in FF is set to 0 after calling xhr.abort().
This difference causes an effect in ExtJS 4.1, that timedout requests mistaken as valid responses. I've used the following override to handle the timeout scenario. In ExtJS 4.1 a variable on the request objects marks if a timeout has occured. The override replaces the onComplete method.
The change can be found on line 856 in the original place in Connection.js. I've extendedCode:Ext.define('Df.data.Connection', { override: 'Ext.data.Connection', onComplete : function(request) { var me = this, options = request.options, result, success, response; try { result = me.parseStatus(request.xhr.status); } catch (e) { // in some browsers we can't access the status if the readyState is not 4, so the request has failed result = { success : false, isException : false }; } success = result.success && !request.timedout; if (success) { response = me.createResponse(request); me.fireEvent('requestcomplete', me, response, options); Ext.callback(options.success, options.scope, [response, options]); } else { if (result.isException || request.aborted || request.timedout) { response = me.createException(request); } else { response = me.createResponse(request); } me.fireEvent('requestexception', me, response, options); Ext.callback(options.failure, options.scope, [response, options]); } Ext.callback(options.callback, options.scope, [options, success, response]); delete me.requests[request.id]; return response; } });
to :Code:success = result.success;
If there is a more convenient way for solving this problem please let me know!Code:success = result.success && !request.timedout;
I've asked that question initially on : http://stackoverflow.com/questions/1...36707_13476325
Best Regards
Chris
-
20 Nov 2012 3:12 PM #2
I can't reproduce this using 4.1.1 (or the latest code) on Chrome 23.0.1271.64 m
Code:Ext.require('*'); Ext.onReady(function() { Ext.Ajax.timeout = 3000; Ext.Ajax.request({ url: 'data.php', success: function(){ console.log('success'); }, failure: function(response){ console.log('failure', response.timedout, response.status, response.aborted); } }); });When I run it, it ends up logging:Code:<?php sleep(10); ?>
Please post more information.Code:failure true 0 undefined
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
21 Nov 2012 12:20 AM #3
I've just found this in production.
ExtJS 4.1 and Mac OSX 1.0.7.4 with Chrome 22.0.1229.94
The trick is to get the request to timeout while receiving data, not while waiting or connecting.
-
21 Nov 2012 12:32 AM #4
sorry, forgot to add this here :
The problem occurs exactly as you say lager, when data is still being received.
-
21 Nov 2012 1:33 AM #5
Correct Bug request
Correct Bug request
Ext version tested:
- Ext 4.1 Build date: 2012-04-20 14:10:47 (19f55ab932145a3443b228045fa80950dfeaf9cc)
- Chrome Version 23.0.1271.64
Description:- see above
- post AJAX request - force timeout during data transmission
- on timeout failure callback should be called
- failure callback was not called on timeout
- see above
- MacOS X 10.8.2
You found a bug! We've classified it as
EXTJSIV-7797
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.


Reply With Quote