Skip to content

jsonrpc: fire onClose from IPCMessageWriter and PortMessageReader - #1903

Merged
Dirk Bäumer (dbaeumer) merged 2 commits into
microsoft:mainfrom
trivikr:json-rpc-on-close
Oct 21, 2026
Merged

Dirk Bäumer (dbaeumer) merged 2 commits into
microsoft:mainfrom
trivikr:json-rpc-on-close

Conversation

@trivikr

Copy link
Copy Markdown
Contributor

Fixes: #1901

IPCMessageWriter and PortMessageReader in jsonrpc/src/node/main.ts registered 'close' listeners as () => this.fireClose, which returns the method without calling it. As a result, their onClose event never fired.

Symmetric pairs (IPC reader + IPC writer, Port reader + Port writer) still closed the connection, because the other half fires onClose correctly. Code that subscribes to onClose on these classes directly, or that pairs one of them with a different transport, never got a close notification. In the mixed-transport case, MessageConnection never reached Closed.

Their 'close' listeners returned this.fireClose instead of calling it,
so the onClose event never fired. Symmetric IPC/Port reader-writer
pairs still closed the connection through the other half, but direct
onClose subscribers and mixed-transport connections got no close
notification.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fixes directly address the reported defect, with regression coverage and no unresolved findings.

No open issues 🎉

What changed in this PR

Fixes #1901 by restoring close notifications in two Node JSON-RPC transports.

Changes:

  • Calls fireClose() in IPCMessageWriter and PortMessageReader.
  • Adds regression tests checking reader and writer close notifications for both transports.

Tests were not run; the repository checkout was unavailable.

File Description
jsonrpc/​src/​node/​test/​connection.test.ts Adds transport close-event regression tests.
jsonrpc/​src/​node/​main.ts Invokes the two previously uncalled close handlers.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 21, 2026 06:34
@dbaeumer
Dirk Bäumer (dbaeumer) enabled auto-merge (squash) October 21, 2026 06:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrow fixes address the reported failures, and regression tests cover both affected transports with no unresolved findings.

No open issues 🎉

Review effort: Balanced

@dbaeumer
Dirk Bäumer (dbaeumer) merged commit bd5fcdd into microsoft:main Oct 21, 2026
5 checks passed
@dbaeumer Dirk Bäumer (dbaeumer) added this to the 3.18.5 milestone Oct 21, 2026
@trivikr
Trivikram Kamat (trivikr) deleted the json-rpc-on-close branch October 26, 2026 19:09
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.

IPCMessageWriter and PortMessageReader never fire onClose

5 participants