Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome cancels streaming/long-polling request when maybe navigating away #1126

Closed
Legioth opened this issue Jun 6, 2013 · 2 comments
Closed

Comments

@Legioth
Copy link
Contributor

Legioth commented Jun 6, 2013

When the user clicks a link in Chrome, the browser cancels all outstanding requests. This causes problems if the link does not cause the page to be unloaded, e.g. if the link goes to a mailto url or something that starts a download instead of loading a new page. Just reopening the streaming/long-polling XHR will not work because Chrome silently ignores any XHRs opened until it realizes that the page will indeed not get unloaded.

I have investigated this situation in a different context. The only reliable way that I then found for handling this is to keep doing send() on the same XHR object until you get an exception saying that the XHR has already been opened or until you observe that the readystate is no longer 1. See http://dev.vaadin.com/ticket/8891#comment:9 for details.

Tested using the chat sample from the head of the atmosphere-1.0.x branch by adding a mailto-link to the page.

@jfarcand
Copy link
Member

jfarcand commented Jun 6, 2013

Hi, can you point me to a library that already implements this behavior? Seems to be a scary change :-)

@Legioth
Copy link
Contributor Author

Legioth commented Jun 6, 2013

This is how I implemented it for Vaadin http://dev.vaadin.com/changeset/008dd4cf731522543c80ea81c0d5dca35f85c90b/vaadin

The situation is however slightly different there as there is typically not any connection that should be kept open all the time but instead just avoiding issues if a request is pending while the user does something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants