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:
- Allowing
_scheduleReconnection to be overridden (make it protected or provide a hook)
- Accepting a custom scheduler function in the transport options
- 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
Summary
The
_scheduleReconnectionmethod inStreamableHTTPClientTransportis currently private and usessetTimeoutfor 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:
Proposed Solution
Make reconnection behavior customizable, either by:
_scheduleReconnectionto be overridden (make it protected or provide a hook)Use Cases
Related