coder / code-server

VS Code in the browser
https://coder.com
MIT License
68.32k stars 5.6k forks source link

the download process makes me confuse #6954

Closed chenm0520 closed 1 month ago

chenm0520 commented 2 months ago

Is there an existing issue for this?

OS/Web Information

Steps to Reproduce

Just download a file (size >100M)

Expected

we know that the file is transmitted by the websocket, so when the download box exists, the file blob data is in the memory, and if I shutdown the code-server, the download process can still continue

Actual

when I shutdown the code-server, the download box shows network error right now, and what makes me more confuse follows, if I proxy the code-server by nginx, when I shutdown the code-server,the download box can still do the download process, but the speed of download will be limit if I configure limit_rate. Is the file downloaded twice?

Logs

No response

Screenshot/Video

No response

Does this bug reproduce in native VS Code?

Yes, this is also broken in native VS Code

Does this bug reproduce in GitHub Codespaces?

Yes, this is also broken in GitHub Codespaces

Are you accessing code-server over a secure context?

Notes

No response

code-asher commented 2 months ago

I imagine it just depends on if code-server is shut down before it finishes transmitting the file. I would not consider it a bug that a file transfer fails when code-server is shut down in the middle of it though.

chenm0520 commented 2 months ago

I imagine it just depends on if code-server is shut down before it finishes transmitting the file. I would not consider it a bug that a file transfer fails when code-server is shut down in the middle of it though. Suppose the download process needs the code-server's running。 how to explain the phenomenon of downloading twice? resuming the file from memory is very fast, but its speed depends on the bandwidth of network

code-asher commented 2 months ago

I might not be understanding, but I tested a 101 MiB file with v4.92.2 and it only downloads once for me.

chenm0520 commented 2 months ago

I might not be understanding, but I tested a 101 MiB file with v4.92.2 and it only downloads once for me. I will give a example with some screenshots,when the websocket's transmission of file is over, the chrome shows 1724729218024 and if you click keep this time , it do the process of copying from memory, it will be very fast, but when I click,it shows 1724729241120 the speed of this resuming is just the bandwidth of network. that's why I think the download process has finished twice. maybe the filesize is not large, using some file about 300M-400M? or trying more times?

code-asher commented 2 months ago

Ohhhhh I see, if the download is blocked by Chrome then it redownloads. I am not sure what we can do from code-server, if Chrome decides it needs to download again then our hands are tied. Maybe Chrome has a limit on how much it will keep in memory, which is why it only happens to larger files.

chenm0520 commented 2 months ago

Ohhhhh I see, if the download is blocked by Chrome then it redownloads. I am not sure what we can do from code-server, if Chrome decides it needs to download again then our hands are tied. Maybe Chrome has a limit on how much it will keep in memory, which is why it only happens to larger files.

`<!DOCTYPE html>

WebSocket File Download

` I guess that it isn't due to the memory limit of browser. I have just written this simple demo to test websocket download in the same browser, Even a File is larger than 1G, the above-mentioned problem did not occur.

code-asher commented 2 months ago

Oh dope awesome test!

Does the same thing happen if you use the file system API? I see this in VS Code: https://github.com/microsoft/vscode/blob/231deb14cd5a978343f722e9ac5207b0ae0dd607/src/vs/workbench/contrib/files/browser/fileImportExport.ts#L755-L756 using FileSystemDirectoryHandle: getFileHandle() and FileSystemFileHandle: createWritable().

They do fall back to the anchor element method if the file system API is not available though.

code-asher commented 1 month ago

I will close for now, if there is an issue it will need to be fixed upstream in VS Code, but definitely feel free to keep commenting if you come back to this.