Open rmosolgo opened 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.
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:
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:
Define turboVisit
to repeatedly visit a new page with Turbolinks:
function turboVisit(fromI, untilI, timeout) {
// toggle between pages in the app:
var path = window.location.pathname == "/stations" ? "/people" : "/stations"
if (fromI < untilI) {
setTimeout(function() { turboVisit(fromI + 1, untilI, timeout) }, timeout)
}
console.log(fromI + ": => " + window.location.pathname)
Turbolinks.visit(path)
}
Make 120 visits, 400ms apart:
// toggle pages 120 times, with a 400ms break in between
turboVisit(0, 120, 400)
Wait:
Interestingly, calling turboVisit(0, 120, 1000)
yields a slightly different outcome (104 successful pushState
calls):
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?
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?)