Skip to content

feat(client): timeout link plugin#1697

Merged
dinwwwh merged 3 commits into
middleapi:mainfrom
dinwwwh:claude/timeout-link-plugin-19e4ec
Jul 20, 2026
Merged

feat(client): timeout link plugin#1697
dinwwwh merged 3 commits into
middleapi:mainfrom
dinwwwh:claude/timeout-link-plugin-19e4ec

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Jul 20, 2026

Copy link
Copy Markdown
Member

Summary

Adds TimeoutLinkPlugin, which automatically aborts requests that exceed a given timeout with an AbortError. The timeout can be static or resolved per request, and returning null/undefined disables it (e.g. for long-lived requests).

const link = new RPCLink({
  plugins: [
    new TimeoutLinkPlugin({
      timeout: ({ context, path }) => context.timeout ?? 10_000,
    }),
  ],
})

Changes

  • TimeoutLinkPlugin in @orpc/client/plugins, works with any link
  • anyAbortSignal helper in @orpc/shared, preferring the built-in AbortSignal.any when available
  • Tests with 100% coverage for both
  • Docs page: /docs/plugins/timeout

Add TimeoutLinkPlugin that aborts requests exceeding a static or
per-request dynamic timeout with an AbortError, plus an anyAbortSignal
helper in @orpc/shared that prefers the built-in AbortSignal.any.
@vercel

vercel Bot commented Jul 20, 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, Comment Jul 20, 2026 2:04pm

@pkg-pr-new

pkg-pr-new Bot commented Jul 20, 2026

Copy link
Copy Markdown
More templates

@orpc/arktype

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

@orpc/bun

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

@orpc/client

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

@orpc/cloudflare

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

@orpc/contract

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

@orpc/experimental-effect

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

@orpc/evlog

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

@orpc/json-schema

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

@orpc/nest

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

@orpc/next

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

@orpc/openapi

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

@orpc/opentelemetry

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

@orpc/pinia-colada

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

@orpc/pino

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

@orpc/publisher

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

@orpc/ratelimit

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

@orpc/server

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

@orpc/shared

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

@orpc/tanstack-query

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

@orpc/trpc

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

@orpc/valibot

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

@orpc/zod

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

commit: 19cac76

@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 critical issues — two minor wording notes inline.

Reviewed changes — a new client TimeoutLinkPlugin that aborts requests after a configured timeout, plus a shared anyAbortSignal helper that merges the caller-provided signal with a plugin-managed timeout signal.

  • Added TimeoutLinkPlugin with static or per-request timeout, disabled by null/undefined
  • Added anyAbortSignal helper that prefers AbortSignal.any and falls back to a manual event-listener implementation
  • Added tests for the plugin and both signal code paths, plus a VitePress docs page and nav entry

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

Comment thread packages/client/src/plugins/timeout.ts Outdated
Comment thread apps/content/docs/plugins/timeout.md
@codspeed-hq

codspeed-hq Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing dinwwwh:claude/timeout-link-plugin-19e4ec (6daef47) with main (4dd9f41)

Open in CodSpeed

@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.

ℹ️ New commit review — the export snapshot addition is the only change, and it looks correct.

Reviewed changes since 7104711 — commit 19cac766 adds TimeoutLinkPlugin to the packages/client/src/plugins/index.test.ts export snapshot, matching the new export * from './timeout' and keeping the public-surface assertion complete.

No new issues introduced by this commit.

Pullfrog  | Fix it ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dinwwwh
dinwwwh merged commit eee680d into middleapi:main Jul 20, 2026
7 of 8 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