Skip to content

fix(client): stop the ClientRetryPlugin retry delay when the signal aborts - #2549

Merged
dinwwwh merged 2 commits into
middleapi:1.xfrom
mark1russell7:fix/retry-delay-abort
Nov 25, 2026
Merged

dinwwwh merged 2 commits into
middleapi:1.xfrom
mark1russell7:fix/retry-delay-abort

Conversation

@mark1russell7

Copy link
Copy Markdown

Closes #2548

On 1.x, ClientRetryPlugin waits its retry delay with a bare setTimeout. An abort of the call's signal during the delay does not end the wait: the call rejects only when the delay ends, and one more request goes out first.

This change:

  • waits with an abortable delay, the same delayExecution(ms, signal) that RetryAfterPlugin on 1.x uses;
  • after the delay, if the signal is aborted, calls the onRetry cleanup with false and rejects with the last error, as the existing branch for an aborted iterator does. No more requests go out.

main already does this with sleep(retryDelayMs, { signal }), so this is only for 1.x.

Test: should stop waiting and not retry if signal is aborted during the retry delay in packages/client/src/plugins/retry.test.ts. It uses fake timers, a 10 s delay and an abort after the first failure. It fails on 1.x (the call never settles, so the test times out) and passes with this change. pnpm vitest run packages/client/src/plugins/retry.test.ts: 22 passed. ESLint is clean on the two files.

An AI coding assistant (Claude Code) wrote the fix, the test and this text.

🤖 Generated with Claude Code

…borts

The retry delay was a bare setTimeout, so an abort during the delay did
not end the wait: the call rejected only when the delay ended. The delay
now ends at the abort, and the call rejects with the last error and sends
no more requests, as RetryAfterPlugin does.

Closes middleapi#2548

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6849ef9c-3e37-4358-8849-23c3c396f3d1

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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

Important

The new abort path rejects with the previous attempt's error instead of the abort reason, so caller-initiated cancellations are reported as failures.

Approach: sound — the retry delay is now abort-aware and the loop checks the signal before issuing another request, which fixes the cause rather than the symptom and mirrors the main fix.

Reviewed changes

  • Abortable retry delay — ClientRetryPlugin now waits with a private delayExecution(ms, signal) instead of a bare setTimeout, and leaves the retry loop when the call's signal aborted during the wait.
  • Regression test — aborts during a 10 s retry delay with fake timers and asserts one request only, the onRetry cleanup called with false, and no pending timers.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Comment thread packages/client/src/plugins/retry.ts Resolved
Comment thread packages/client/src/plugins/retry.ts Resolved
@pkg-pr-new

pkg-pr-new Bot commented Nov 25, 2026

Copy link
Copy Markdown
More templates

@orpc/ai-sdk

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

@orpc/arktype

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

@orpc/client

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

@orpc/contract

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

@orpc/experimental-durable-iterator

npm i https://pkg.pr.new/@orpc/experimental-durable-iterator@2549

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@2549

@orpc/interop

npm i https://pkg.pr.new/@orpc/interop@2549

@orpc/json-schema

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

@orpc/nest

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

@orpc/openapi

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

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@2549

@orpc/otel

npm i https://pkg.pr.new/@orpc/otel@2549

@orpc/experimental-pino

npm i https://pkg.pr.new/@orpc/experimental-pino@2549

@orpc/experimental-publisher

npm i https://pkg.pr.new/@orpc/experimental-publisher@2549

@orpc/experimental-publisher-durable-object

npm i https://pkg.pr.new/@orpc/experimental-publisher-durable-object@2549

@orpc/experimental-ratelimit

npm i https://pkg.pr.new/@orpc/experimental-ratelimit@2549

@orpc/react

npm i https://pkg.pr.new/@orpc/react@2549

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@2549

@orpc/experimental-react-swr

npm i https://pkg.pr.new/@orpc/experimental-react-swr@2549

@orpc/server

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

@orpc/shared

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

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@2549

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@2549

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@2549

@orpc/standard-server-fastify

npm i https://pkg.pr.new/@orpc/standard-server-fastify@2549

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@2549

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@2549

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@2549

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@2549

@orpc/tanstack-query

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

@orpc/trpc

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

@orpc/valibot

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

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@2549

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@2549

@orpc/zod

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

commit: 194108a

@codecov

codecov Bot commented Nov 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/client/src/plugins/retry.ts 85.71% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@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

  • Abort reason on cancellation — the abort branch now throws signal.reason, with the last attempt's error kept for the iterator-only case, matching BatchLinkPlugin's error === signal.reason contract.
  • Coverage for both abort timings — the delay test now asserts the rejection is the abort reason and that no timers remain, plus a new test aborts inside onRetry to cover the already-aborted early return.
  • Minor cleanup — a single signal binding and a plain-return early exit in delayExecution.

Verified on the head commit: vitest run packages/client/src/plugins/retry.test.ts → 23 passed.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@dinwwwh
dinwwwh merged commit 387552c into middleapi:1.x Nov 25, 2026
2 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.

2 participants