go-sdk/internal/jsonrpc2
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Bobo 165121e53e
jsonrpc2: wrap write error in server-closing error (#1186)
The "server is closing" error produced when a connection shuts down
because its write side failed formatted the underlying write error with
`%v`, so the cause - typically `io.EOF` when a stdio host closes its
pipe - was not part of the error chain. A caller that wants to
distinguish a clean host disconnect from a real failure via
`errors.Is(err, io.EOF)` therefore always got `false`.

This changes both `s.writeErr` wrappings to use `%w`, preserving the
write error in the error chain while keeping the same message text
("server is closing: EOF").

A regression test exercises the write-failure branch of `shuttingDown`
and asserts both `errors.Is(err, ErrServerClosing)` and `errors.Is(err,
io.EOF)`.

Fixes #1098

---------

Co-authored-by: Bo Zhang <187063395+Tethys0@users.noreply.github.com>
Co-authored-by: Guglielmo Colombo <guglielmoc@google.com>
2026-08-27 14:12:53 +00:00
..
conn.go jsonrpc2: wrap write error in server-closing error (#1186) 2026-08-27 14:12:53 +00:00
conn_test.go jsonrpc2: wrap write error in server-closing error (#1186) 2026-08-27 14:12:53 +00:00
jsonrpc2.go internal/jsonrpc2: remove unused code (#910) 2026-04-28 09:56:15 +02:00
messages.go fix(jsonrpc2): decode requests when method key is present (#1000) 2026-06-16 09:57:18 +02:00
wire.go internal/jsonrpc2: test WireError.Is and fix nil target panic (#1079) 2026-08-21 10:56:31 +02:00
wire_test.go internal/jsonrpc2: test WireError.Is and fix nil target panic (#1079) 2026-08-21 10:56:31 +02:00