MITM Not Receiving MessageChannel on writer.close()
See original GitHub issueBrowser: Chrome Version 80.0.3987.132
Issue:
Calling writer.close() on a WritableStreamDefaultWriter results in a TypeError in the mitm (showing up in my web app Chrome console). The full error is: Uncaught TypeError: [StreamSaver] You didn't send a messageChannel at onMessage (mitm.html?version=2.0.0:66). Stepping through the StreamSaver code, it seems like it occurs after this end message gets sent in the StreamSaver.js main file on line 279:
close () {
if (useBlobFallback) {
........
} else {
channel.port1.postMessage('end')
}
},
Code: Here’s a basic implementation that is resulting in this error message:
fetch("http://localhost:8075")
.then((resp) => {
const writer = streamSaver.createWriteStream("test_file.csv").getWriter();
const reader = resp.body.getReader();
const pump = () => reader.read()
.then((res) => {
if (res.done) {
writer.close();
} else {
writer.write(res.value)
.then(pump);
}
});
pump();
});
The code runs fine in Safari, but I get that console error in Chrome. Other than the console error, the download seems to be working fine in Chrome. Any idea why i’m seeing this? Is it related to using an insecure site for development? Let me know if you need more info - any help you can offer is greatly appreciated.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Top Related StackOverflow Question
Hmm, not sure what it is. can’t reproduce.
respondWith(resulting in a 404 error). instead it generates a blob and usea[download]#69if the download is doing just fine then maybe you don’t have anything to worry about. it could be that something else is posting messages to any iframe that exist in the DOM tree. you could try putting a breakpoint at the message event at look what the message data look like.
I have this very same problem on mac using Firefox and Chrome. The download works ok, only this message appears on console after the download is completed. I use this in a Vue.js app.
Here is the code I use to download: