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

Fix header decoding sometimes failing in the browser #164

Merged

Conversation

FrederikBolding
Copy link
Contributor

Header decoding would sometimes fail in the browser due to mixing of polyfilled Buffer and Uint8Array. I found two instances of calling toString() directly on a Uint8Array eventually leading to the checksum failing. This would happen semi-rarely based on the performance of the stream writing to tar-stream.

I have replaced the toString() calls with usage of b4a.

@mafintosh
Copy link
Owner

Great find, thanks

@mafintosh mafintosh merged commit 298d3d4 into mafintosh:master Jan 19, 2024
3 checks passed
@FrederikBolding FrederikBolding deleted the fix-browser-race-condition branch January 19, 2024 07:28
FrederikBolding added a commit to MetaMask/metamask-extension that referenced this pull request Jan 19, 2024
## **Description**

`tar-stream` has a bug where it randomly fails to decode tar headers due
to mixing of `Uint8Array` and polyfilled `Buffer`. I have upstreamed a
fix for this, but while we wait for it to be released, this patch should
fix the issue!

Context on the bug: mafintosh/tar-stream#164
@FrederikBolding
Copy link
Contributor Author

Great find, thanks

You're welcome! I will admit, it took a while to track this one down 😅

If you could let me know once a new version is published, that would be much appreciated! That'll let me remove some patches 😅

@mafintosh
Copy link
Owner

Done, 3.1.7

@FrederikBolding
Copy link
Contributor Author

Appreciate it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants