fix: opt out of response compression to avoid Node 24+ fetch gzip bug#62
Draft
fix: opt out of response compression to avoid Node 24+ fetch gzip bug#62
Conversation
On Node 24+, global `fetch` can return raw gzipped bytes for compressed responses, which breaks `res.json()` with "Unexpected token '...' is not valid JSON". Reproduced on Node 26 against handbook.doist.com via `ol auth status` and the OAuth login flow's `auth.info` call. Send `Accept-Encoding: identity` so the server returns an uncompressed payload, sidestepping the issue across Node versions. Mirrors the fix landed in twist-sdk-typescript#126. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
7 tasks
4 tasks
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
ol auth status(and the OAuth login flow'sauth.infostep) failing on Node 24+ withUnexpected token '...' is not valid JSON—res.json()was choking on raw gzipped response bytes.Accept-Encoding: identityon every API request so the server returns an uncompressed payload, sidestepping whatever decompression path Node mishandles.Background
Same family of bug as
Doist/twist-sdk-typescript#126. That PR framed it as "only with a custom undici dispatcher", butolreproduces the symptom on Node 26 againsthandbook.doist.comusing barefetchwith no custom dispatcher. The smallest robust fix is the same one the SDK landed on: opt out of response compression entirely. Cost is uncompressed JSON, negligible for this CLI's small payloads.Test plan
npm run type-checknpm test— 77/77 passing (api.test.ts header assertion updated)npm run build && node dist/index.js auth statusagainsthandbook.doist.comon Node 26 — prints team/user (was failing pre-fix)ol auth login --token <token>end-to-end on Node 26 (token-flow exercises the sameapiRequestpath)🤖 Generated with Claude Code