Skip to content

feat(docs): add gzip compression to docs-ledger publish requests#16033

Draft
broady wants to merge 6 commits into
feat/docs_ledgerfrom
devin/1779332916-ledger-gzip-compression
Draft

feat(docs): add gzip compression to docs-ledger publish requests#16033
broady wants to merge 6 commits into
feat/docs_ledgerfrom
devin/1779332916-ledger-gzip-compression

Conversation

@broady
Copy link
Copy Markdown
Contributor

@broady broady commented May 21, 2026

Description

Refs FER-10484

Adds transparent gzip compression to docs-ledger publish request bodies (register, finish, preview register) using the oRPC SDK's built-in fetch option. Full typed client is preserved — no raw fetch calls.

Depends on https://github.com/fern-api/fern-platform/pull/11324 (adds fetch option to CreateDocsLedgerClientOptions).

Changes Made

  • New compressedLedgerFetch.ts: streaming gzip via CompressionStream API, passed as custom fetch to createDocsLedgerClient
  • publishDocsLedger.ts: uses createGzipFetch() for register + finish calls
  • publishDocsLedgerPreview.ts: uses createGzipFetch() for preview register + finish calls
  • Changelog entry added

How it works

  1. oRPC's LinkFetchClient serializes the body into a Request object with a ReadableStream body
  2. Our custom fetch pipes the body through new CompressionStream("gzip") (Web Streams API)
  3. Sets Content-Encoding: gzip header, removes Content-Length (chunked transfer)
  4. FDR's @fastify/compress transparently decompresses on the server side

Testing

  • Manual testing completed
  • CI compile/test failures are pre-existing on feat/docs_ledger — the published @fern-api/fdr-sdk doesn't include the orpc-client module yet. Biome, depcheck, boundaries, lint-pr-title all pass.

Link to Devin session: https://app.devin.ai/sessions/39280dca1e9e4499ab649331c7809231
Requested by: @broady

@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@github-actions
Copy link
Copy Markdown
Contributor

🌱 Seed Test Selector

Select languages to run seed tests for:

  • Python
  • TypeScript
  • Java
  • Go
  • Ruby
  • C#
  • PHP
  • Swift
  • Rust
  • OpenAPI

How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR.

devin-ai-integration Bot and others added 6 commits May 21, 2026 05:25
Co-Authored-By: cbro <cbro@buildwithfern.com>
Co-Authored-By: cbro <cbro@buildwithfern.com>
… calls

Co-Authored-By: cbro <cbro@buildwithfern.com>
Co-Authored-By: cbro <cbro@buildwithfern.com>
Co-Authored-By: cbro <cbro@buildwithfern.com>
Co-Authored-By: cbro <cbro@buildwithfern.com>
@devin-ai-integration devin-ai-integration Bot force-pushed the devin/1779332916-ledger-gzip-compression branch from 4c37296 to 6605a3a Compare May 21, 2026 05:26
Comment on lines +217 to +223
const savedFetch = globalThis.fetch;
globalThis.fetch = createGzipFetch();
const fdr = createFdrService({
token: token.value,
...(Object.keys(headers).length > 0 && { headers })
});
globalThis.fetch = savedFetch;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical: Global state corruption on error

If createFdrService() throws an exception, globalThis.fetch will remain permanently modified to the gzip-compressing version, affecting all subsequent fetch calls in the process. This will cause subsequent non-compressed endpoints to receive gzipped data they don't expect.

Fix: Wrap in try/finally:

const savedFetch = globalThis.fetch;
try {
    globalThis.fetch = createGzipFetch();
    const fdr = createFdrService({
        token: token.value,
        ...(Object.keys(headers).length > 0 && { headers })
    });
} finally {
    globalThis.fetch = savedFetch;
}
Suggested change
const savedFetch = globalThis.fetch;
globalThis.fetch = createGzipFetch();
const fdr = createFdrService({
token: token.value,
...(Object.keys(headers).length > 0 && { headers })
});
globalThis.fetch = savedFetch;
const savedFetch = globalThis.fetch;
let fdr;
try {
globalThis.fetch = createGzipFetch();
fdr = createFdrService({
token: token.value,
...(Object.keys(headers).length > 0 && { headers })
});
} finally {
globalThis.fetch = savedFetch;
}

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@broady broady marked this pull request as draft May 21, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants