Multiple onNotification/onRequest registration - #65
Merged
Merged
Conversation
- Enhanced `ARCHITECTURE.md` to include new types and internal utilities. - Added ADRs for two-sided cancellation bridge, webview participant union type, disposable return from handler registration, and handler registration enforcement. - Introduced `util.ts` for shared internal utilities. - Updated package versions to 0.7.0 across all relevant packages. - Implemented breaking changes in handler registration to enforce unique request and notification handlers. - Updated tests to reflect new handler registration behavior and ensure proper error handling.
dhuebner
force-pushed
the
dhuebner/handler-registration-63
branch
from
August 28, 2026 11:20
0022b01 to
557008e
Compare
jonah-iden
approved these changes
Aug 28, 2026
jonah-iden
left a comment
Contributor
There was a problem hiding this comment.
Looks pretty good to me.
I guess registering a handler first for notification and request can only happen if you don't define your message types correctly beforehand right? Otherwise it would already be catched at compile time. But still good to have that extra security.
documentation also looks pretty good to me
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 #63
Registering overlapping
onRequest/onNotificationhandlers previously failed silently(webview side: last registration wins,
dispose()could remove the wrong handler) or onlysurfaced as a runtime dispatch error (host side: "Multiple matching request handlers").
This PR enforces handler invariants at registration time on both sides:
registering the opposite kind throws immediately.
onRequestfor the same method throws if itssenderscope overlaps an existing one (host side); the webview side allows at most onerequest handler per method.
onNotificationstill stacks freely - all matching handlers fire.Disposable.dispose()removes by identity, not by method name, so stacked notificationhandlers can be managed independently.
See ADR-0004 for the full design rationale
and breaking-change notes (shipped as a minor version bump under 0.x SemVer, v0.7.0).
Also includes: ADRs 0001-0003 documenting prior design decisions, updated
ARCHITECTURE.md,new
vscode-messenger-common/src/util.tsfor shared participant/error-message helpers, andexpanded test coverage for the new registration-enforcement behavior on both host and webview
sides.