Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unusual behaviour when downloading partial chunks #1621

Open
traktion opened this issue Apr 16, 2024 · 2 comments
Open

Unusual behaviour when downloading partial chunks #1621

traktion opened this issue Apr 16, 2024 · 2 comments
Labels
Bug Something isn't working

Comments

@traktion
Copy link

I've enabled streaming in my sn_httpd client using the files API, but I uncovered some unusual behaviour.

The associated code is here: https://github.com/traktion/sn_httpd/blob/163e59181502e6783b71027ed55328ad7f5920f1/src/main.rs#L170

When using STREAM_CHUNK_SIZE smaller than a safe net chunk size (up to 512 KB, I believe), there seems to be unexpected overlapping data returned.

For example, when using 131072 as the STREAM_CHUNK_SIZE, one of my test images was being corrupted. On closer inspection with Wireshark, it looked like two bytes were being repeated on the subsequent call.

I took the output from Wireshark and compared it. I've attached a screenshot of the difference:

Screenshot from 2024-04-16 09-53-55

When using much smaller STREAM_CHUNK_SIZE, it exacerbates the issue (although performance suffers regardless).

I can't see any issues in my code and it looks like position is being measured / applied incorrectly somewhere within this code block (inc. dependencies):

if let Ok(data_map) = self.unpack_chunk(chunk.clone()).await {

I haven't seen any issues when downloading with position == 0 and MAX length, but for very large files, it's inefficient for streaming using that technique.

@JasonPaulGithub
Copy link
Contributor

Amazing work @traktion
I will cc @RolandSherwin about this and mark the issue as a bug for now. Thanks!

@JasonPaulGithub JasonPaulGithub added the Bug Something isn't working label Apr 16, 2024
@traktion
Copy link
Author

From digging more into this, I tracked down the issue to self_encryption and I have a fix for it. I'll create a PR on that repo instead and we can close this one out if/when it's confirmed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants