Closed pxdl closed 5 months ago
This will probably get fixed in #1237, we need to update tauri api version to apply the fix made in https://github.com/tauri-apps/tauri/pull/9463
New packages were released, can you make sure to update all tauri related packages (both rust and js) and then try again?
After updating all packages to the latest version, this bug seems to have been fixed, thank you!
After some testing, I noticed that the plugin worked fine at first, even when downloading large files. But now it doesn't seem to be working properly, it seems to choke when sending updates to the channel and only properly updates when the download finishes, especially with large files. After this happens, lots of errors pop up on the console after reloading the page, which can be further detailed in the Network tab:
These errors keep popping up until I restart the program completely, reloading the page isn't enough.
This is how I'm updating the download progress state (I'm passing down the handleDownloadProgress
function to where I call the plugin):
function reducer(state, action) {
switch (action.type) {
case 'reset':
return { total: 0, downloaded: 0 };
case 'downloaded_chunk':
return {
downloaded:
action.total !== state.total
? action.chunk
: state.downloaded + action.chunk,
total: action.total,
};
default:
throw Error('Unknown action.');
}
}
function Updater() {
const [downloadState, dispatchDownloadState] = useReducer(reducer, {
total: 0,
downloaded: 0,
});
const handleDownloadProgress = ({
progress,
total,
}: {
progress: number;
total: number;
}) => {
dispatchDownloadState({ type: 'downloaded_chunk', chunk: progress, total });
};
return (
<Text>{`${downloadState.downloaded} bytes / ${downloadState.total} bytes`}</Text>
);
}
Here's a small gif showing what happens. This was working fine a while ago, updating in real time:
Fairly sure this is not the plugin's fault but an issue with the Channel api. I could swear i talked about this somewhere before but i can't find the issue or discord discussion 🤔
It seems related to this issue on the tauri repository: https://github.com/tauri-apps/tauri/issues/8177
Given that the issue doesn't seem to be related to the plugin, but to the channel API, I'm closing it again.
@FabianLars I noticed that you implemented some sort of workaround on https://github.com/tauri-apps/plugins-workspace/commit/dd8bc4ab399582e876f84116333b3e29bf3ceee6, are there any plans to implement event emission throttling on the main branch?
I'm not sure if it's really 8177. This emit issue makes the whole app crash while we're just talking about lost events. Considering that we're talking about v1 vs v2 it may be the same issue just without the crash due to refactoring, not sure.
As long as we're in beta (hoping that we figure out the issue) i won't add the throttle. Once we're running out of time and don't have a fix, i'll add it though.
When trying to download zip files using the @tauri-apps/plugin-upload plugin, the progress callback isn't reporting the correct length of the chunks being downloaded.
Here's an example (using console.log) of the total chunks reported not matching the entire size of the file:
Here's an example of the total chunks reported properly matching the actual size of the file:
Some bigger files also work and other don't, so I don't think it has to do with the size of the file.
Here's my JavaScript code calling the @tauri-apps/plugin-upload plugin:
Is there some kind of compression going on during the download? How to report the actual progress?