IE continues executing JS after a 302 is received?

So, I've run into a bit of a weird issue, and I'm hoping there are some IE savants out there who may be able to shed some light on this behavior. My company runs a realtime Lift application. We use the comet model for realtime communication between browsers and the server, as is standard with Lift. Also worth noting: In the event that comets get out of sync with the server (either because of connection issues or a server restart, anything that would kill the session on the server) the server responds to that comet request with a document.location.reload(); to reload the page, start up a new session, and so on.

Now, to ensure that logouts happen as they should, we have a special url (/session/logout) that does all the session-related cleanup then kicks you back to our homepage. This can either be triggered by clicking an anchor to that URL or the server may issue you a 302 to that URL if you try to do something that requires you to be logged out. Simple enough, right? In most browsers, this works great because the workflow looks something like this:

  1. User either clicks the logout button or the server sends a 302 to /session/logout
  2. Javascript execution on the current page stops, so all comets shut down.
  3. Browser loads /session/logout
  4. Browser received 302 message from server (signifying the session cleanup is done) to kick the user to the homepage.
  5. Browser loads homepage.

However, in IE we're seeing the following behavior:

  1. User either clicks the logout button or the server sends a 302 to /session/logout
  2. Browser starts loading /session/logout
  3. Browser recieved 302 message from server (signifying the session cleanup is done) to kick the user to the homepage.
  4. Browser starts loading homepage.
  5. Comets receive a document.location.reload(); from the server because they were never shut down by IE, the loading of the homepage is aborted, and the current page is reloaded without the user logged in.

This is entirely undesirable because we need the correct result of the /session/logout to load -- especially in situations where a user was trying to do something that they couldn't do when they were logged in (in that case the 302 returned from logout would point to wherever they were originally trying to go to).

Has anyone run up against this kind of issue before? Any advice on how to deal with this issue?

Answers


I don't know anything about comet, specifically, but you should be more explicit in the shutting down of comet.

I would recommend capturing the window.onbeforeunload event and explicitly shutting down comet instead of relying on the browser to do this work for you.


Need Your Help

How do I merge adjacent SPAN tags in an XML document?

xml dom powershell html

We have some XML documents that contain a bit of XHTML in bits. The HTML has come out of MS Word or something and there's lots of adjacent SPAN tags that are exactly the same, except for their con...