fix: work around Bun fetch ZlibError on compressed responses#105
Open
maciej wants to merge 1 commit intosteipete:mainfrom
Open
fix: work around Bun fetch ZlibError on compressed responses#105maciej wants to merge 1 commit intosteipete:mainfrom
maciej wants to merge 1 commit intosteipete:mainfrom
Conversation
Bun's compiled binary throws "Decompression error: ZlibError" when fetching certain pages (e.g. theregister.com). This is a known Bun bug in its streaming zlib decompression pipeline — it mishandles edge cases with chunked + gzip/br responses that Node.js processes fine. Changes: - Set Accept-Encoding to "gzip, deflate" (exclude brotli) in all REQUEST_HEADERS to avoid the most problematic codec. - Add isZlibError() detection and automatic retry with "Accept-Encoding: identity" in fetchHtmlDocument(), so if Bun's decompression still fails on gzip, the request is retried without any compression. Upstream Bun issues: - oven-sh/bun#23149 (open — ZlibError) - oven-sh/bun#18413 (ShortRead variant) - oven-sh/bun#8017 (original report) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Accept-Encoding: gzip, deflateAccept-Encoding: identityWhy
Bun currently throws
Decompression error: ZlibErroron some compressed/chunked responses that Node handles correctly.No matching upstream summarize issue was found, so this PR is posted directly as requested.