feat: add custom reconnection scheduler for non-persistent environments #1177
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #1162
Summary
Adds support for custom reconnection scheduling to
StreamableHTTPClientTransport, enabling proper reconnection handling in non-persistent environments like serverless functions, mobile apps, and desktop applications wheresetTimeoutis insufficient or unavailable.Motivation and Context
As discussed in #1162 and the review feedback from PR #1129, the current
_scheduleReconnectionmethod relies onsetTimeout, which doesn't work well for:This PR implements the custom scheduler approach (option 2 from the original issue), providing maximum flexibility while maintaining full backward compatibility.
How Has This Been Tested?
src/client/streamableHttp.test.ts: Added comprehensive test suite with 4 new test cases:Breaking Changes
None. This is a fully backward-compatible addition:
reconnectionScheduleris not provided, the transport uses the defaultsetTimeout-based schedulerTypes of changes
Checklist
Review Notes
This is one of my early contributions to the project. I've followed the existing patterns and conventions to the best of my ability,
but I'm very open to feedback on:
Thank you for taking the time to review 🙌