Ticket #1896 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

strategy-cluster.html example fails after reloading in IE6 and IE7

Reported by: ahocevar Owned by: fredj
Priority: minor Milestone: 2.8 Release
Component: Protocol Version: 2.7
Keywords: Cc:
State: Complete

Description

 http://n2.nabble.com/Fwd%3A-IE-cluster-protocol-error---%27status%27-is-null-or-not-an-object-td1836423.html#a20830502

The example only works in IE when loading it for the first time. Reloading it, or using it when it is still in the browser cache, will cause it to fail with a "status is null or not an object" error in the handleResponse method of Protocol/HTTP.js. This has to be investigated further. What makes IE finally break is that the priv property of the response is null, but until now I have no idea why.

Attachments

1896-r8616-A0.patch Download (0.5 KB) - added by ahocevar 4 years ago.
request.patch Download (0.5 KB) - added by tschaub 4 years ago.
make return available before sending data
request-async.patch Download (0.7 KB) - added by ahocevar 4 years ago.
request.2.patch Download (2.5 KB) - added by tschaub 4 years ago.
delay for cached docs in ie

Change History

in reply to: ↑ description   Changed 4 years ago by igrcic

Replying to ahocevar:

 http://n2.nabble.com/Fwd%3A-IE-cluster-protocol-error---%27status%27-is-null-or-not-an-object-td1836423.html#a20830502 The example only works in IE when loading it for the first time. Reloading it, or using it when it is still in the browser cache, will cause it to fail with a "status is null or not an object" error in the handleResponse method of Protocol/HTTP.js. This has to be investigated further. What makes IE finally break is that the priv property of the response is null, but until now I have no idea why.

Yes var request = resp.priv; in Protocol.HTTP on line 322 is null. I remember I added one extra check on line 324, to see if request is truthy if(request&&(request.status>=200&&request.status<300))

Since then I dont get this error thrown in IE, obviously. I know its not the right way to do it, but as I dont know much about background of the error, its workable temporary solution for me.

  Changed 4 years ago by ahocevar

Ok, after some investigation it seems that IE fires an onReadyState event with readyState=4 immediately (i.e. before the creation of the request object is finished) if the requested document is already in the cache. The fix Ivan tried is almost correct, it just has to be done one line above to avoid a FAILURE response code in the Protocol:

    handleResponse: function(resp, options) {
        var request = resp.priv;
        if(request && options.callback) {
        ...

Fortunately, the onReadyStateChange will still be fired again properly with readyState=4 after the request object is created, so the handleResponse method will be called again, and this time with the priv property set.

Patch to come in a few minutes.

Changed 4 years ago by ahocevar

  Changed 4 years ago by ahocevar

  • state set to Review

  Changed 4 years ago by tschaub

  • state changed from Review to Needs Discussion

I'm curious to see if we can address this a bit further upstream. Please check the upcoming patch to see if this solves the issue.

Changed 4 years ago by tschaub

make return available before sending data

follow-up: ↓ 6   Changed 4 years ago by ahocevar

Tim: I am convinced that your patch is the right way to do it. Just tested in IE, and it resolves the issue.

Just one concern: I think this breaks applications where people issue requests with async=false when they expect to work with request.responseText or request.responseXML right after returning from request.issue.

in reply to: ↑ 5   Changed 4 years ago by ahocevar

Replying to ahocevar:

Just one concern: I think this breaks applications where people issue requests with async=false when they expect to work with request.responseText or request.responseXML right after returning from request.issue.

Not only applications will break, but also parts of OpenLayers. Format.KML for instance, which does the following:

    fetchLink: function(href) {
        var request = OpenLayers.Request.GET({url: href, async: false});
        if (request) {
            return request.responseText;
        }
    },

Maybe we could use the setTimeout only when async==true. Attaching a patch which does that.

Changed 4 years ago by ahocevar

  Changed 4 years ago by ahocevar

  • state changed from Needs Discussion to Review

  Changed 4 years ago by igrcic

Tried the patch, works in IE7! Thank you Andreas

Changed 4 years ago by tschaub

delay for cached docs in ie

  Changed 4 years ago by tschaub

  • state changed from Review to Commit

Tests need to be modified to accommodate this change. We only have one case where we are testing send with an asynchronous call. The latest patch tests with a delay.

Please commit if you confirm tests pass in IE.

  Changed 4 years ago by ahocevar

Tests also pass in IE. Thanks Tim for the important contributions to this fix, thanks Ivan and Tim for the review.

  Changed 4 years ago by ahocevar

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [8816]) fixed a caching issue with asynchronous requests in IE. r=igrcic, tschaub (closes #1896)

Note: See TracTickets for help on using tickets.