Skip to content

Allow customizable reconnection behavior for non-persistent clients #1162

@felixweinberger

Description

@felixweinberger

Summary

The _scheduleReconnection method in StreamableHTTPClientTransport is currently private and uses setTimeout for scheduling reconnection attempts. This doesn't work well for clients that aren't running continuously (e.g., serverless functions, mobile apps that need push notifications to wake up).

Motivation

From PR #1129 review comment by @mattzcarey:

not for this PR but it would be good to be able to overwrite this method. For clients which aren't running all the time this will need some input externally from the client itself to wake it up.

Proposed Solution

Make reconnection behavior customizable, either by:

  1. Allowing _scheduleReconnection to be overridden (make it protected or provide a hook)
  2. Accepting a custom scheduler function in the transport options
  3. Emitting an event when reconnection is needed, letting the client handle scheduling

Use Cases

  • Serverless/edge functions that can't maintain long-running timers
  • Mobile apps that need to schedule reconnection via platform-specific mechanisms (push notifications, background fetch)
  • Desktop apps that need to handle sleep/wake cycles

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Significant bug affecting many users, highly requested featureenhancementRequest for a new feature that's not currently supportedgood first issueGood for newcomersready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions