How come? XHR.readyState==4 && this.status==0

673 views
Skip to first unread message

Brice Laurencin

unread,
Nov 17, 2011, 11:13:38 AM11/17/11
to chromi...@chromium.org
Hi every one!

I am having a hard time hunting for a bug. Consider this code (business
parts removed to protect the innocents):

xhr.onreadystatechange = function() {
if (this.readyState != 4) {
debug("state was not 4, it was " + this.readyState);
return;
}
debug("state was 4, status is "+this.status);
if (this.status == 200 && this.responseText) {
//(blablabla)
handleSuccess();
return;
}
debug("no response text..., status is "+ this.status);
handleError();
};

In the console, I end up having things like:

[DEBUG] state was not 4, it was 1
[DEBUG] state was not 4, it was 2
[DEBUG] state was not 4, it was 3
[DEBUG] state was not 4, it was 3
[DEBUG] state was not 4, it was 3
[DEBUG] state was not 4, it was 3
[DEBUG] state was not 4, it was 3
[DEBUG] state was 4, status is 200
[DEBUG] no response text..., status is 200
[DEBUG] Handling error

[DEBUG] state was not 4, it was 1
[DEBUG] state was 4, status is 0
[DEBUG] no response text..., status is 0

[DEBUG] state was not 4, it was 1
[DEBUG] state was 4, status is 0
[DEBUG] no response text..., status is 0

[DEBUG] state was not 4, it was 1
[DEBUG] state was 4, status is 0
[DEBUG] no response text..., status is 0

How come I have such results?

Those are highly unexpected, and happen completely randomly. Some users
see it, some don't. It is quite common upon extension installation, but
works ok on browser or manual reload.
One thing lessens the frequency: this code is called using a
window.timeout. If I call it through a direct call (using an other
feature of the extension), it works most of the time (not every time).


Thanks for your time!
Brice.

Paul Kinlan

unread,
Nov 17, 2011, 1:25:21 PM11/17/11
to Brice Laurencin, chromi...@chromium.org
Hi,

Normally people use xhr.readyState, xhr.status and xhr.responseText rather than "this"

P


Brice.

--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To post to this group, send email to chromi...@chromium.org.
To unsubscribe from this group, send email to chromium-apps+unsubscribe@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/?hl=en.




--
Paul Kinlan
Developer Advocate @ Google for Chrome and HTML5

Scott Fujan

unread,
Nov 17, 2011, 2:19:42 PM11/17/11
to Paul Kinlan, chromi...@chromium.org, Brice Laurencin

Looks like a bad connection to the server to me. Are you DDOSing yourself? That said, I really don't see how this pertains to chrome apps directly.

To unsubscribe from this group, send email to chromium-app...@chromium.org.

Brice Laurencin

unread,
Nov 18, 2011, 9:10:16 AM11/18/11
to chromi...@chromium.org
Ok, maybe not the best place to ask, sorry.

thanks for your help!
Brice.

Le jeu. 17 nov. 2011 20:19:42 CET, Scott Fujan a écrit :
> Looks like a bad connection to the server to me. Are you DDOSing
> yourself? That said, I really don't see how this pertains to chrome
> apps directly.
>
> On Nov 17, 2011 12:25 PM, "Paul Kinlan" <paulk...@google.com

> chromi...@chromium.org <mailto:chromi...@chromium.org>.


> To unsubscribe from this group, send email to

> chromium-apps+unsubscribe@__chromium.org
> <mailto:chromium-apps%2Bunsu...@chromium.org>.


> For more options, visit this group at

> http://groups.google.com/a/__chromium.org/group/chromium-__apps/?hl=en
> <http://groups.google.com/a/chromium.org/group/chromium-apps/?hl=en>.


>
>
>
>
> --
> Paul Kinlan
> Developer Advocate @ Google for Chrome and HTML5
> G+: http://plus.ly/paul.kinlan

> t: +447730517944 <tel:%2B447730517944>


> tw: @Paul_Kinlan
> LinkedIn: http://uk.linkedin.com/in/paulkinlan
> Blog: http://paul.kinlan.me
> Skype: paul.kinlan
>
> --
> You received this message because you are subscribed to the Google
> Groups "Chromium Apps" group.
> To post to this group, send email to chromi...@chromium.org

> <mailto:chromi...@chromium.org>.


> To unsubscribe from this group, send email to

> chromium-app...@chromium.org
> <mailto:chromium-apps%2Bunsu...@chromium.org>.

Reply all
Reply to author
Forward
0 new messages