Skip to content

Conversation

crickeys
Copy link
Contributor

[rant]Personally I have to use xhr-polling because websockets still have a rising memory usage until I run out of memory. [/rant]

When using xhr-polling I need to know when a visitor changes pages on the site so I use opts['sync disconnect on unload'] = true;

However, I've noticed that if the node server is having trouble keeping up or some network connection issue, then this unload function halts the browser (I think this is because the xhr request is sync, which it needs to be in order to reach the server).

I discovered that some browsers respect a timeout setting on an xhr object. So, this commit gives you a new option to set opts['sync disconnect timeout'] = 300; // ms

It defaults to 0, so it will have the same original behavior. Otherwise you can set a number in ms for the function to timeout if the server doesn't respond.

@crickeys
Copy link
Contributor Author

After further review, I'm not sure that any of the browser respect the timeout if the xhr request is sync. I think they only listen if it is async. :(

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant