Search code examples
ruby-on-railsinternet-explorer-11outlook-addinturbolinks

Unspecified error with Turbolinks in Outlook and IE11


We're getting unspecified error in our Outlook Add-In that uses IE as its browser engine. The error comes from our compiled application.js javascript file that traces into Turbolinks.

This error occurs when we load our application in our Outlook add-in integration. There is a loading page that determines if the user needs to log in, and if not, will redirect them into our application.


Solution

  • This is one of those bugs you bang your head on for days or weeks and then it turns out to be a one line fix.

    TLDR;

    window.location.replace(url) is dangerous as it doesn't update history. This means the user won't be able to click the back button. But also, it means with frameworks like Turbolinks that manipulate history you have to be careful.

    Instead, use: window.location.assign(url)

    The long story: In our Outlook Add-In's landing page that determines whether to prompt for login or redirect to the application, we were using window.location.replace. For some reason (that I can't fully explain) when our application loads, there is Turbolinks processing that tries to call "replaceState" on the window's history object.

    For some reason, when the first page you access, redirects with replace, there is an empty history that causes unspecified error in IE.

    The fix is simply to do a proper history adding redirect using location.assign(url).