Skip to content

fix(client): respect user-provided mapSubresponse in BatchLinkPlugin - #1848

Merged
dinwwwh merged 1 commit into
middleapi:mainfrom
dinwwwh:claude/clever-brattain-2867c7
Aug 12, 2026
Merged

fix(client): respect user-provided mapSubresponse in BatchLinkPlugin#1848
dinwwwh merged 1 commit into
middleapi:mainfrom
dinwwwh:claude/clever-brattain-2867c7

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Aug 12, 2026

Copy link
Copy Markdown
Member

A custom mapSubresponse passed to BatchLinkPlugin was silently ignored: the constructor assigned the built-in implementation unconditionally instead of using the options.mapSubresponse ?? ... fallback that every other option uses. Users who supplied the hook to rewrite sub-responses got the default header merge instead, with no error or warning.

Fixes

A user-provided mapSubresponse now runs for every sub-request, and the response it returns (headers and body alike) is what reaches the caller. Behavior is unchanged when the option is omitted.

Testing

New test in packages/client/src/plugins/batch.test.ts supplies a custom mapSubresponse that tags headers and rewrites the body, then asserts it is called once per sub-request, that its headers reach the codec, and that its body is what link.call resolves to. The batch response carries its own header so the test also confirms the default merge is replaced rather than layered on. The test fails on the unpatched plugin and passes with the fix.

The constructor assigned the default implementation unconditionally
instead of using the `options.mapSubresponse ?? ...` fallback every
other option uses, so a custom mapSubresponse was silently ignored.
@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
orpc Ready Ready Preview Aug 12, 2026 2:30am

@pullfrog pullfrog Bot left a comment

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.

✅ No new issues found.

Reviewed changes

  • batch.ts:164BatchLinkPlugin constructor now honors a user-provided mapSubresponse via options.mapSubresponse ?? <default>, fixing the silent ignore bug. Matches the ?? default pattern used by every other option.
  • batch.test.ts:411 — new test supplying a custom mapSubresponse (tags headers, rewrites body), asserting it runs once per sub-request and its headers/body reach the codec and caller, and that the default batch-header merge is replaced rather than layered on.

The fix is minimal and correct, and the test genuinely fails on the unpatched code — without the fix mapSubresponse would never be called, the resolved body would be result-0 instead of mapped-result-0, and the batch response header would still be merged. Default behavior (option omitted) is unchanged, and no JSDoc update is needed since @default still describes the default. Verified: pnpm vitest run packages/client/src/plugins/batch.test.ts → 28 passed.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pkg-pr-new

pkg-pr-new Bot commented Aug 12, 2026

Copy link
Copy Markdown
More templates

@orpc/ai-sdk

npm i https://pkg.pr.new/@orpc/ai-sdk@1848

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@1848

@orpc/bun

npm i https://pkg.pr.new/@orpc/bun@1848

@orpc/client

npm i https://pkg.pr.new/@orpc/client@1848

@orpc/cloudflare

npm i https://pkg.pr.new/@orpc/cloudflare@1848

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@1848

@orpc/experimental-effect

npm i https://pkg.pr.new/@orpc/experimental-effect@1848

@orpc/evlog

npm i https://pkg.pr.new/@orpc/evlog@1848

@orpc/hibernation

npm i https://pkg.pr.new/@orpc/hibernation@1848

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@1848

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@1848

@orpc/next

npm i https://pkg.pr.new/@orpc/next@1848

@orpc/node

npm i https://pkg.pr.new/@orpc/node@1848

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@1848

@orpc/opentelemetry

npm i https://pkg.pr.new/@orpc/opentelemetry@1848

@orpc/pinia-colada

npm i https://pkg.pr.new/@orpc/pinia-colada@1848

@orpc/pino

npm i https://pkg.pr.new/@orpc/pino@1848

@orpc/publisher

npm i https://pkg.pr.new/@orpc/publisher@1848

@orpc/ratelimit

npm i https://pkg.pr.new/@orpc/ratelimit@1848

@orpc/server

npm i https://pkg.pr.new/@orpc/server@1848

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@1848

@orpc/swr

npm i https://pkg.pr.new/@orpc/swr@1848

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@1848

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@1848

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@1848

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@1848

commit: e8de387

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 30 untouched benchmarks


Comparing dinwwwh:claude/clever-brattain-2867c7 (e8de387) with main (18576d4)

Open in CodSpeed

@dinwwwh
dinwwwh merged commit 1d6dbe6 into middleapi:main Aug 12, 2026
12 checks passed
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.

1 participant