Skip to content

fix(powernap): use req.Notif to detect notifications in Router#790

Open
lexh wants to merge 1 commit intocharmbracelet:mainfrom
lexh:fix/powernap-router-id-zero
Open

fix(powernap): use req.Notif to detect notifications in Router#790
lexh wants to merge 1 commit intocharmbracelet:mainfrom
lexh:fix/powernap-router-id-zero

Conversation

@lexh
Copy link
Copy Markdown

@lexh lexh commented Mar 2, 2026

Router.Route compared req.ID to jsonrpc2.ID{} to distinguish notifications from requests. Since jsonrpc2.ID{} has Num: 0, any server-initiated request with integer ID 0 (e.g. the first outgoing request from lsp_server/ty) was misrouted as a notification, skipping its registered handler entirely.

Use req.Notif instead, which is correctly set by Request.UnmarshalJSON based on whether the "id" field is present in the JSON.

Also guard against nil req.Params to prevent panics when a server sends a request or notification without a params field.

  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

Router.Route compared req.ID to jsonrpc2.ID{} to distinguish
notifications from requests. Since jsonrpc2.ID{} has Num: 0, any
server-initiated request with integer ID 0 (e.g. the first outgoing
request from lsp_server/ty) was misrouted as a notification, skipping
its registered handler entirely.

Use req.Notif instead, which is correctly set by Request.UnmarshalJSON
based on whether the "id" field is present in the JSON.

Also guard against nil req.Params to prevent panics when a server
sends a request or notification without a params field.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant