Repository navigation
fix(client): stop the ClientRetryPlugin retry delay when the signal aborts - #2549
Conversation
…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>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
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 —
ClientRetryPluginnow waits with a privatedelayExecution(ms, signal)instead of a baresetTimeout, 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
onRetrycleanup called withfalse, and no pending timers.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/client
@orpc/contract
@orpc/experimental-durable-iterator
@orpc/hey-api
@orpc/interop
@orpc/json-schema
@orpc/nest
@orpc/openapi
@orpc/openapi-client
@orpc/otel
@orpc/experimental-pino
@orpc/experimental-publisher
@orpc/experimental-publisher-durable-object
@orpc/experimental-ratelimit
@orpc/react
@orpc/react-query
@orpc/experimental-react-swr
@orpc/server
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-aws-lambda
@orpc/standard-server-fastify
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/standard-server-peer
@orpc/svelte-query
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…ng the retry delay
There was a problem hiding this comment.
✅ 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, matchingBatchLinkPlugin'serror === signal.reasoncontract. - 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
onRetryto cover the already-aborted early return. - Minor cleanup — a single
signalbinding and a plain-return early exit indelayExecution.
Verified on the head commit: vitest run packages/client/src/plugins/retry.test.ts → 23 passed.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Closes #2548
On
1.x,ClientRetryPluginwaits its retry delay with a baresetTimeout. An abort of the call'ssignalduring the delay does not end the wait: the call rejects only when the delay ends, and one more request goes out first.This change:
delayExecution(ms, signal)thatRetryAfterPluginon1.xuses;onRetrycleanup withfalseand rejects with the last error, as the existing branch for an aborted iterator does. No more requests go out.mainalready does this withsleep(retryDelayMs, { signal }), so this is only for1.x.Test:
should stop waiting and not retry if signal is aborted during the retry delayinpackages/client/src/plugins/retry.test.ts. It uses fake timers, a 10 s delay and an abort after the first failure. It fails on1.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