Skip to content

Retry transient Durable Object routing failures#399

Merged
threepointone merged 1 commit into
mainfrom
routing-retry-do-errors
May 11, 2026
Merged

Retry transient Durable Object routing failures#399
threepointone merged 1 commit into
mainfrom
routing-retry-do-errors

Conversation

@threepointone
Copy link
Copy Markdown
Collaborator

Summary

  • Adds routingRetry support to PartyServer routing so transient Durable Object infrastructure errors are retried at the routePartykitRequest / getServerByName boundary.
  • Retries only errors with retryable === true, never retries overloaded errors, recreates the DO stub per attempt, and clones routed requests so request bodies remain replayable.
  • Documents the new option, adds a patch changeset, and covers retry opt-out/observer/body/hook/error edge cases in tests.

Details

This keeps retry handling in PartyServer instead of requiring downstream frameworks or apps to wrap every routePartykitRequest / routeAgentRequest call site. User routing hooks (onBeforeConnect / onBeforeRequest) still run once before the retry boundary, so retries do not repeat auth or request-mutation hooks.

routingRetry defaults to 3 attempts with jittered exponential backoff (100ms base, 800ms cap). It can be disabled with routingRetry: false or configured with maxAttempts, baseDelayMs, maxDelayMs, and onRetry.

Test plan

  • npx vitest -r src/tests src/tests/index.test.ts --watch false
  • npm run check:type
  • npm run check:format
  • npm run check:lint

Made with Cursor

PartyServer now retries transient Durable Object infrastructure errors at the routing boundary so callers do not need to wrap every routeAgentRequest or routePartykitRequest use site themselves. The retry path is scoped to retryable, non-overloaded runtime errors and recreates the DO stub/request per attempt while avoiding rerunning user routing hooks.

This also exposes routingRetry configuration, documents the option, and covers retry, opt-out, overload, non-retryable, exhausted, body replay, and onRetry observer edge cases.

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 11, 2026

🦋 Changeset detected

Latest commit: 03e3aad

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

This PR includes changesets to release 1 package
Name Type
partyserver 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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 11, 2026

Open in StackBlitz

hono-party

npm i https://pkg.pr.new/cloudflare/partykit/hono-party@399

partyfn

npm i https://pkg.pr.new/cloudflare/partykit/partyfn@399

partyserver

npm i https://pkg.pr.new/cloudflare/partykit/partyserver@399

partysocket

npm i https://pkg.pr.new/cloudflare/partykit/partysocket@399

partysub

npm i https://pkg.pr.new/cloudflare/partykit/partysub@399

partysync

npm i https://pkg.pr.new/cloudflare/partykit/partysync@399

partytracks

npm i https://pkg.pr.new/cloudflare/partykit/partytracks@399

partywhen

npm i https://pkg.pr.new/cloudflare/partykit/partywhen@399

y-partyserver

npm i https://pkg.pr.new/cloudflare/partykit/y-partyserver@399

commit: 03e3aad

@threepointone threepointone merged commit f772382 into main May 11, 2026
6 checks passed
@threepointone threepointone deleted the routing-retry-do-errors branch May 11, 2026 21:43
@github-actions github-actions Bot mentioned this pull request May 11, 2026
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