PDA

View Full Version : Error when connectivity is patchy or fails.



eeb
6 Jan 2011, 11:47 AM
This is kind of hard to repro, but sometimes when I am sending an ajax request using Ext.Ajax.request and my connection is bad or goes bad, I get the following error:


JavaScript Error on Line 17402 http://192.168.2.1:88...sencha-touch-debug.js TypeError: Result of expression 'r.xhr' [undefined] is not an object.

I can sometimes make it happen if I turn off wifi in the middle of a submit.

I noticed that at the line of code where the error occurs there is not check for undefined:

onComplete : function(r) {
var status = r.xhr.status, <--- Line 1402
options = r.options,
success = true,
response;

Can anyone else reproduce this issue? I will post a bug report if I can figure out a consistent repro, because it seems like the finding xhr to be undefined should fire a failure event.

Thanks!

chinj
22 Feb 2011, 12:00 AM
I got the same error while using the Ext.Ajax function.

The error occurs while it returns status 0,

There is a slight alteration needed somewhere here.


Ext.override(Ext.data.Connection, {
onComplete : function(r) {
if(r.xhr.status){

var status = r.xhr.status,
options = r.options,
success = true,
response;

if ((status >= 200 && status < 300) || status == 304) {
response = this.createResponse(r);
this.fireEvent('requestcomplete', this, response, options);
if (options.success) {
if (!options.scope) {
options.success(response, options);
}
else {
options.success.call(options.scope, response, options);
}
}
}
else {
success = false;
switch (status) {
case 12002:
case 12029:
case 12030:
case 12031:
case 12152:
case 13030:
response = this.createException(r);
break;
default:
response = this.createResponse(r);
}
this.fireEvent('requestexception', this, response, options);
if (options.failure) {
if (!options.scope) {
options.failure(response, options);
}
else {
options.failure.call(options.scope, response, options);
}
}
}
} else {
response = this.createResponse(r);
this.fireEvent('requestexception', this, response, options);
}


if (options.callback) {
if (!options.scope) {
options.callback(options, success, response);
}
else {
options.callback.call(options.scope, options, success, response);
}
}

delete this.requests[r.id];
}
});