Bug 8765 - Ajax error handling in prototype based skins does not capture timeout
: Ajax error handling in prototype based skins does not capture timeout
Status: CLOSED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Skins
: 7.2
: All Other
: P3 normal (vote)
: 7.x
Assigned To: Michael Herger
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-07-17 03:34 UTC by Joerg Schwieder
Modified: 2009-07-31 10:24 UTC (History)
0 users

See Also:
Category: ---


Attachments
patch as mentioned above (597 bytes, patch)
2008-07-17 03:34 UTC, Joerg Schwieder
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joerg Schwieder 2008-07-17 03:34:51 UTC
Created attachment 3612 [details]
patch as mentioned above

The global.js in EN cancels an AjaxRequest manually after a timeout but does not reduce the number of waiting requests resulting in spinners never being removed and error handler never being called.

Attached is a fix. It manually reduces prototype's "Ajax.activeRequestCount", when aborting.

The bug has been in global.js for a while (at least since the 7.0beta) but I patched the version from 7.2. Should not make a big difference since it's in the first lines of code in that file.

Fix tested in iPeng for a while.
Comment 1 Michael Herger 2008-07-17 10:18:49 UTC
Just to be sure I understand: what we're doing here is create kind of a timeout check for AJAX calls, because it doesn't exist in prototypejs?
Comment 2 Michael Herger 2008-07-17 10:33:17 UTC
change 21833 - thanks!
Comment 3 Joerg Schwieder 2008-07-17 11:01:38 UTC
Well, more or less: yes.

To be clear: I didn't invent this, it was already there, I just fixed the bug in it.

Prototype offers Ajax responders that notify you about any Ajax activity going on. In global.js these are used for two purposes:
a) to show and remove the spinner (and associated text) while something is loading
b) the timeout

I don't know, whether prototype has it's own timeout mechanism and it just get's shortcut or whether this is an addition (I think there was no timeout without that code so probably prototype doesn't have it or it's not being used).
What the code does is: whenever there's a notification of a new request coming in, it sets a timeout of 30s. After that timeout, the request is aborted and the error callback is called.

Now for the buggy part:
global.js also removes the spinner when all requests are finished and it misses this one because prototype does not update it's internal counter when you abort a request (you could call this a prototype error).
In the code that I originally modified there was also an erroneous error callback but that's obviously fixed ;-)

For SC's skins this is only a small issue since after you run into a timeout no spinners will ever be removed again until you reload the page since then there's a leftover request on the stack, so to say. And I don't know whether there's other responders (to the closing of the last request) that will never be called.

I fixed this since it was a more severe issue for iPeng since I included other cleanup code into this responder.
Comment 4 Michael Herger 2008-07-17 14:01:00 UTC
> I don't know, whether prototype has it's own timeout mechanism and it just

From reading prototypejs.com and some comments on there I'd say no. Many users are asking for it though.
Comment 5 Chris Owens 2008-07-30 15:31:36 UTC
This bug has now been fixed in the 7.1 release version of SqueezeCenter!  Please download the new version from http://www.slimdevices.com if you haven't already.  

If you are still experiencing this problem, feel free to reopen the bug with your new comments and we'll have another look.
Comment 6 Chris Owens 2009-07-31 10:24:54 UTC
Reduce number of active targets for SC