Skip to content

retryLink over wsLink: a retried request is never sent, so it hangs #7886

Closed

Description

@KATT

🤖 With retryLink in front of wsLink and the default retryDelayMs (0), a retry never reaches the server. A retried query's promise never settles. A retried subscription stops after the error and never resumes, and onError and onComplete are never called.

const t = initTRPC.create();
let calls = 0;
const router = t.router({
  flaky: t.procedure.query(() => {
    if (++calls === 1) throw new TRPCError({ code: 'INTERNAL_SERVER_ERROR' });
    return 'ok';
  }),
});
// ...serve `router` with applyWSSHandler...

const client = createTRPCClient<typeof router>({
  links: [
    retryLink({ retry: (opts) => opts.attempts < 3 }),
    wsLink({ client: createWSClient({ url }) }),
  ],
});

await client.flaky.query(); // never settles; the server is called once

Expected: the retry is sent. The query resolves 'ok', and a subscription resumes from its last event id.

Actual: nothing more is sent after the first error. With retryDelayMs: () => 10 it works.

Root cause: retryLink retries synchronously with the same op.id, so the retry is registered while the failed request is still being cleaned up. That cleanup deletes requests by id (requestManager.ts:79 via wsClient.ts:234, and again at wsClient.ts:419), which also removes the retry before it is sent.

Activity

  1. added a commit that references this issue on Nov 4, 2026
    fb22efc
  2. github-actions commented on Nov 5, 2026

    @github-actions
    Contributor

    This issue has been locked because we are very unlikely to see comments on closed issues. If you are running into a similar issue, please create a new issue. Thank you.

  3. locked as resolved and limited conversation to collaborators on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions