Repository navigation
Conversation
- Add deliverLocally() call after adapter.publish() for adapters without start() - Fix wire format: JSON.stringify envelope with proper shape stripping - Strip internal excludeClientId from wire meta before serialization - Handle JSON serialization errors gracefully (BigInt, circular refs) - Fix lifecycle ordering: getOrCreateClientId() runs before handleInternalOpen() - Update memory adapter to accept excludeSelf (plugin handles filtering) - Add comprehensive local-delivery.test.ts with 12 test cases - Update docs to reflect excludeSelf is now supported Closes #106
The pubsub plugin now handles excludeSelf universally: - Plugin adds excludeClientId to envelope.meta when excludeSelf is true - deliverLocally() filters out the sender during fan-out - Distributed adapters (Redis, Bun) pass envelope through to broker - Consumer callback (deliverLocally) handles filtering on delivery Changes: - Remove excludeSelf rejection from Redis and Bun adapters - Update plugin header to document excludeClientId filtering - Update types.ts to remove "not yet implemented" comment - Update docs (api-reference.md, ADR-019, pubsub README) - Fix superficial test assertions to expect success
Bun's server.publish() broadcasts directly with no way to intercept delivery or enumerate subscribers. This makes excludeSelf architecturally impossible. Changes: - Bun adapter returns UNSUPPORTED for excludeSelf with clear explanation - Strip internal fields (excludeClientId) from wire message defensively - Update Bun adapter docs to explain the limitation - Update pubsub.md spec to document adapter-specific behavior - Update api-reference.md with adapter support notes
- Update pubsub README with Bun limitation note - Update context-methods.md spec with adapter support note - Update ADR-030 with adapter support note - Add regression test for Bun excludeSelf returning UNSUPPORTED
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #108 +/- ##
==========================================
+ Coverage 82.17% 82.54% +0.37%
==========================================
Files 78 79 +1
Lines 6249 6399 +150
==========================================
+ Hits 5135 5282 +147
- Misses 1114 1117 +3
🚀 New features to boost your workflow:
|
redisPubSub(redis) now auto-creates a subscriber connection via duplicate() during router.pubsub.init(), eliminating the need to manually create two connections. ### Changes - Auto-duplicate subscriber when client supports duplicate() - Fail-fast validation when subscriber === publisher - start() conditional based on subscriber capability - Fixed connection leak on init failure - Fixed sync exception handling (separate decode vs callback errors) - Export type: PubSubDriver → PubSubAdapter ### Docs - Updated all examples to simplified pattern - Aligned migration guide with unified adapter architecture - Fixed missing imports in code snippets
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #106
Summary
duplicate()for simplified setupexcludeSelfuniversally at plugin layerProblem
When @isak102 reported that messages weren't showing up between browser tabs in the chat example, the root cause was that the memory adapter wasn't delivering messages to local subscribers. Additionally, Redis setup required verbose boilerplate with two connections.
Solution
1. Local Delivery for Memory Adapter
The pubsub plugin now handles local delivery for adapters without broker ingestion:
2. Redis Auto-Subscriber
redisPubSub(redis)now auto-creates a subscriber viaduplicate():Changes
excludeSelffiltering at plugin layerduplicate(), fail-fast validation, connection leak fixesexcludeSelf(Bun's native pub/sub limitation)Adapter Capabilities
Test Plan
bun test packages/pubsub— local delivery tests (420+ lines)bun test packages/redis— auto-subscriber, fail-fast, cleanup testsbun test packages/memory— memory adapter testsbun test packages/bun— Bun adapter tests