Skip to content

fix(plugin-fetch): avoid relying on global BodyInit in Node projects - #839

Open
stijnvanhulle wants to merge 1 commit into
mainfrom
claude/github-issue-833-ibtsje
Open

fix(plugin-fetch): avoid relying on global BodyInit in Node projects#839
stijnvanhulle wants to merge 1 commit into
mainfrom
claude/github-issue-833-ibtsje

Conversation

@stijnvanhulle

Copy link
Copy Markdown
Contributor

🎯 Changes

@kubb/plugin-fetch and @kubb/plugin-axios emit generated client and serializer files that referenced the global BodyInit type. A Node-only TypeScript project (@types/node without the dom library) declares RequestInit, Request, and Response globally, but not BodyInit, so the generated code failed to type-check with Cannot find name 'BodyInit'.

Both templates now define a module-local RequestBody type derived from RequestInit['body'] and use it everywhere BodyInit was referenced. This resolves the same way BodyInit did in a browser or full-dom project, but no longer depends on a global name a Node-only project doesn't declare.

Fixes #833

Files changed

  • packages/plugin-fetch/templates/fetch.ts and templates/serializers.ts
  • packages/plugin-axios/templates/serializers.ts (shares the same serializer template)
  • Generated snapshots in tests/3.0.x/__snapshots__/ and examples/*/src/gen/.kubb/, refreshed to match
  • docs submodule's snippets/how-to/transport.md updated to match the new type name

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is for the docs (no release).

🤖 Generated with Claude Code

https://claude.ai/code/session_01H2LADp1sJjG9BQz5sQbsBX


Generated by Claude Code

The generated .kubb/client.ts and .kubb/serializers.ts referenced the
global BodyInit type, which a Node-only project (@types/node without
the dom lib) never declares. Both files now use a local RequestBody
type derived from RequestInit['body'], which resolves the same way
without requiring a global BodyInit name. plugin-axios shares the
same serializers.ts template and gets the same fix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H2LADp1sJjG9BQz5sQbsBX
@codesandbox

codesandbox Bot commented Sep 3, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@coldtea-pr-lens

coldtea-pr-lens Bot commented Sep 3, 2026

Copy link
Copy Markdown

◈ PR Lens

🟢 +0 new · 🟠 ~8 changed · 🔴 -0 removed · 0 flows · 12 files · commit eddfd39


Architecture

Architecture diagram for kubb-labs/plugins at eddfd39

8 components touched across 7 lanes.

Open full size


Data flow

No data-flow sequence changed in this PR.


Drill down
HTTP Clients — 2 components
🟡 CHANGED @⁠kubb/plugin-fetch

Fetch API client generator; updated runtime and serializer templates to type request bodies via RequestInit['body'] instead of global BodyInit.

🟡 CHANGED @⁠kubb/plugin-axios

Axios client generator; updated serializer templates to replace global BodyInit references with RequestBody derived from RequestInit.

Examples & Suites — 6 components
🟡 CHANGED Advanced PetStore Pipeline

Advanced pipeline example with regenerated serializers adopting RequestBody.

🟡 CHANGED React Query Example

React Query client example with regenerated runtime client and serializers.

🟡 CHANGED Fetch Client Example

Fetch client example app with regenerated runtime client and serializer files.

🟡 CHANGED Axios Client Example

Axios client example app with regenerated serializer utilities.

🟡 CHANGED MCP Server Example

MCP server example app with updated serializers.

🟡 CHANGED OpenAPI 3.0 Integration Tests

Snapshot integration test suite updated across fetch, axios, mcp, react-query, swr, and vue-query fixtures.


View

  • Architecture lens
  • Data flow lens
  • Expand every detail
  • Show unchanged neighbours

Tip

PR Lens is free for open source. A star on the repository is what keeps it going.

🪧 More tips
  • Run PR Lens on your own machine: npx skills add coldteadotai/pr-lens installs the agent skill. Then tell your coding agent: "Diagram the change you just made with PR Lens and attach it to the pull request."
  • Draw a diff before it is even a pull request: npx @coldtea/pr-lens-cli analyze --base origin/main reads the diff with your own model key, and npx @coldtea/pr-lens-cli render .pr-lens/graph.json draws the same lenses on your machine.
  • The boxes under View are live. Tick Architecture lens or Data flow lens to choose which diagrams appear, or Expand every detail to open every drill-down at once. The comment redraws in place a few seconds later.
  • Show unchanged neighbours lists the components this change did not touch alongside the ones it did, so the drill-down shows what the changed code sits next to.
  • GitHub will not let you zoom an image in a comment. The link under each diagram opens it full size on a page of its own, where you can.
  • The CLI's render picks up .github/pr-lens.yml automatically and applies your corrections (renames, exclusions, lane pins) at draw time.
  • Would you rather run it from CI on a key of your own? Add .github/workflows/pr-lens.yml with coldteadotai/pr-lens/packages/action@v0 and a model key in your repository secrets, say GEMINI_API_KEY. The Action asks Gemini by default, or OpenAI and any endpoint speaking /chat/completions through its provider input.
  • Push a new commit and the whole comment re-renders for the new head. An older run never overwrites a newer one, so a slow render cannot put a stale diagram back.
  • The diagrams follow your GitHub theme, so dark mode gets the dark render and light mode the light one, and the moving dots show this pull request's data in motion.

◈ Rendered by PR Lens · crafted with ❤️ by the Coldtea team · Come say hi on Discord

@changeset-bot

changeset-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: eddfd39

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@kubb/plugin-fetch Patch
@kubb/plugin-axios Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: add610f2-a531-4ab4-a0b4-9bd3887d5962

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 312 kB

ℹ️ View Unchanged
Filename Size
packages/plugin-axios/dist/index.cjs 15.5 kB
packages/plugin-axios/dist/index.js 15 kB
packages/plugin-axios/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-cypress/dist/index.cjs 5.71 kB
packages/plugin-cypress/dist/index.js 5.62 kB
packages/plugin-cypress/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-faker/dist/index.cjs 14.5 kB
packages/plugin-faker/dist/index.js 14.4 kB
packages/plugin-faker/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-fetch/dist/index.cjs 15.5 kB
packages/plugin-fetch/dist/index.js 15 kB
packages/plugin-fetch/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-mcp/dist/index.cjs 10 kB
packages/plugin-mcp/dist/index.js 9.54 kB
packages/plugin-mcp/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-msw/dist/index.cjs 5.81 kB
packages/plugin-msw/dist/index.js 5.72 kB
packages/plugin-msw/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-react-query/dist/index.cjs 17.8 kB
packages/plugin-react-query/dist/index.js 17.2 kB
packages/plugin-react-query/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-redoc/dist/index.cjs 2.21 kB
packages/plugin-redoc/dist/index.js 1.74 kB
packages/plugin-redoc/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-swr/dist/index.cjs 12 kB
packages/plugin-swr/dist/index.js 11.4 kB
packages/plugin-swr/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-ts/dist/index.cjs 23.8 kB
packages/plugin-ts/dist/index.js 23.1 kB
packages/plugin-ts/dist/rolldown-runtime-CNktS9qV.js 291 B
packages/plugin-vue-query/dist/index.cjs 14.8 kB
packages/plugin-vue-query/dist/index.js 14.3 kB
packages/plugin-vue-query/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-zod/dist/index.cjs 19.7 kB
packages/plugin-zod/dist/index.js 19.6 kB
packages/plugin-zod/dist/rolldown-runtime-C0LytTxp.js 168 B

compressed-size-action

@pkg-pr-new

pkg-pr-new Bot commented Sep 3, 2026

Copy link
Copy Markdown
More templates

@kubb/plugin-axios

npm i https://pkg.pr.new/@kubb/plugin-axios@839

@kubb/plugin-cypress

npm i https://pkg.pr.new/@kubb/plugin-cypress@839

@kubb/plugin-faker

npm i https://pkg.pr.new/@kubb/plugin-faker@839

@kubb/plugin-fetch

npm i https://pkg.pr.new/@kubb/plugin-fetch@839

@kubb/plugin-mcp

npm i https://pkg.pr.new/@kubb/plugin-mcp@839

@kubb/plugin-msw

npm i https://pkg.pr.new/@kubb/plugin-msw@839

@kubb/plugin-react-query

npm i https://pkg.pr.new/@kubb/plugin-react-query@839

@kubb/plugin-redoc

npm i https://pkg.pr.new/@kubb/plugin-redoc@839

@kubb/plugin-swr

npm i https://pkg.pr.new/@kubb/plugin-swr@839

@kubb/plugin-ts

npm i https://pkg.pr.new/@kubb/plugin-ts@839

@kubb/plugin-vue-query

npm i https://pkg.pr.new/@kubb/plugin-vue-query@839

@kubb/plugin-zod

npm i https://pkg.pr.new/@kubb/plugin-zod@839

commit: eddfd39

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.

fix(plugin-fetch): avoid relying on global BodyInit in Node projects

2 participants