Skip to content

Feat: add resilient subscription helpers with reconnection and gap recovery - #2007

Open
MayurK-cmd wants to merge 1 commit into
anza-xyz:mainfrom
MayurK-cmd:feat/subscription-reconnection-helpers
Open

Feat: add resilient subscription helpers with reconnection and gap recovery#2007
MayurK-cmd wants to merge 1 commit into
anza-xyz:mainfrom
MayurK-cmd:feat/subscription-reconnection-helpers

Conversation

@MayurK-cmd

Copy link
Copy Markdown

Add createResilientSubscription and coordinateSubscriptionRecovery utilities to help applications build robust WebSocket subscriptions that automatically reconnect on failure and recover from message gaps.

createResilientSubscription wraps a subscription factory with:

  • Automatic reconnection on failure
  • Exponential backoff with jitter (configurable)
  • Optional message gap recovery via onGap callback
  • AbortSignal support for graceful shutdown
  • Async generator interface for streaming results

coordinateSubscriptionRecovery runs multiple recovery functions in parallel and collects any errors, useful for synchronizing catch-up logic across multiple subscriptions after network failures.

Both utilities include comprehensive JSDoc with usage examples and follow Kit conventions (functional composition, TypeScript strict mode, proper error handling).

Closes #1990

Testing: Manual integration tests conducted - all 4 test scenarios pass:

  • Test 1: Basic reconnection with gap recovery ✓
  • Test 2: Parallel recovery coordination ✓
  • Test 3: AbortSignal handling ✓
  • Test 4: Edge case (empty recovery functions) ✓

@changeset-bot

changeset-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5a5883a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mcintyre94

Copy link
Copy Markdown
Member

Thanks for this, but my instinct is that this it too opinionated for Kit. It's definitely too opinionated for packages/rpc-subscriptions. If we did add something like this then we'd probably want it in packages/kit, which is where the higher-level more opinionated functionality lives. But then we'd be positioning this as the default, and that needs some careful design thought from us.

I think this may be better off as an independent package outside of Kit, perhaps published as a Kit Plugin.

@MayurK-cmd

Copy link
Copy Markdown
Author

Thanks for the feedback! Makes sense — I'll publish this as a community plugin instead and open a PR to kit-plugins to get it listed in the Community Plugins table. Appreciate the pointer to that repo.

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.

feat: Add subscription reconnection helpers with automatic recovery

2 participants