You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a rails application with https://turbo.hotwired.dev/ on the frontend. We are using StreamSaver v2.0.4 to handle file downloads in secure context.
We have the next issue with StreamSaver, reproducible with these steps:
User clicks Download link
StreamSaver creates an iframe and downloads the file through it, everything is ok.
User navigates to another page, and there is another Download link
User clicks Download, but nothing happens
User is unable to download anything until they fully reload the page.
Console shows the error:
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'postMessage')
at iframe.postMessage (StreamSaver.js:50:60)
at Object.createWriteStream (StreamSaver.js:251:25)
After some debugging I came to conclusion that this happens because StreamSaver is currently incompatible with turbo-rails, but it can be easily fixed.
Then on step 4 the StreamSaver checks the existence of mitmTransporter, and it's indeed defined, so it skips creating iframe, but the postMessage to it fails, because it's not in the dom anymore.
We have a rails application with https://turbo.hotwired.dev/ on the frontend. We are using StreamSaver v2.0.4 to handle file downloads in secure context.
We have the next issue with StreamSaver, reproducible with these steps:
Download
linkDownload
linkDownload
, but nothing happensConsole shows the error:
After some debugging I came to conclusion that this happens because StreamSaver is currently incompatible with turbo-rails, but it can be easily fixed.
The problem is that on the step 3
turbo
replaces the dom, and the iframe created on the step 2 gets removed, but the reference to it still lives asmitmTransporter
: https://github.com/jimmywarting/StreamSaver.js/blob/2.0.4/StreamSaver.js#L116Then on step 4 the StreamSaver checks the existence of
mitmTransporter
, and it's indeed defined, so it skips creating iframe, but thepostMessage
to it fails, because it's not in the dom anymore.I would propose to change this condition https://github.com/jimmywarting/StreamSaver.js/blob/2.0.4/StreamSaver.js#L115 so that in secure context it also checks existence of
mitmTransporter.contentWindow
. Then it will create the iframe again if it's not in the dom.Does this make sense? I would create a PR.
The text was updated successfully, but these errors were encountered: