turbolinks / turbolinks-classic

Classic version of Turbolinks. Now deprecated in favor of Turbolinks 5.
MIT License
3.54k stars 428 forks source link

Handle errors during onload by a hard page load #669

Open rmosolgo opened 8 years ago

rmosolgo commented 8 years ago

Recently, Safari decided that you can only pushState 100 times. After that, pushState raises "SecurityError: DOM Exception 18". Here is some more info about this change:

https://forums.developer.apple.com/thread/36650 http://codepen.io/mortenolsendk/post/when-safari-broke-webapps

This patch adds error handling to the onload hook when Turbolinks receives a new page. This way, it will catch the pushState error.

I was able to reproduce the error locally, and this patch "fixed" it for me.

(Are you still taking patches for 2-5-stable?)

sstephenson commented 8 years ago

I don’t think you’re likely to encounter this in a real app. It’s a rate limit of 100 state change operations per 30 seconds, not a hard limit of 100 operations.

rmosolgo commented 8 years ago

Thanks for those details!

Somehow, I think it is happening in our app. We've seen it on bugsnag (but I didn't look carefully, I thought it was Safari with localStorage turned off), and finally a user sent a screenshot of his JS console:

image

I'll have to read up on the 30-second limit. I found that I could replicate the issue in a timespan greater than 30 seconds:

If I understand correctly, that's 100 * 0.400 => 40 seconds or 104 * 1 => 104 seconds, so, does that mean we're affected despite the 30s limit? Or have I overlooked something?