Skip to content

fix: Keep the write error in the chain of Encoder errors - #81

Merged
keelerm84 merged 1 commit into
mainfrom
mk/sdk-3225/encoder-wrap-errors
Oct 7, 2026
Merged

keelerm84 merged 1 commit into
mainfrom
mk/sdk-3225/encoder-wrap-errors

Conversation

@keelerm84

@keelerm84 keelerm84 commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Encoder formatted the underlying write error with %v, which turns it into
text. A caller could not use errors.Is or errors.As on the result, so it
could not tell a write deadline cut (os.ErrDeadlineExceeded) from a reset
or a broken pipe without matching the message. The error now wraps with
%w. The message text is unchanged.


Note

Overview
Encoder write failures now preserve the underlying error so callers can use errors.Is / errors.As (e.g. to distinguish os.ErrDeadlineExceeded from connection resets) instead of parsing the message string.

All Encode paths that return "eventsource encode: …" now wrap the io.WriteString error with %w instead of %v; the user-facing message text is unchanged.

Adds TestEncoderKeepsTheWriteErrorInTheChain, covering plain events, comments, and gzip-compressed encoding via a stub writer that always fails.

Reviewed by Cursor Bugbot for commit 8f0b29d. Bugbot is set up for automated code reviews on this repo. Configure here.

Encoder formatted the underlying write error with %v, which turns it into
text. A caller could not use errors.Is or errors.As on the result, so it
could not tell a write deadline cut (os.ErrDeadlineExceeded) from a reset
or a broken pipe without matching the message. The error now wraps with
%w. The message text is unchanged.
@keelerm84
keelerm84 marked this pull request as ready for review October 6, 2026 14:08
@keelerm84
keelerm84 requested a review from a team as a code owner October 6, 2026 14:08
@keelerm84
keelerm84 merged commit 49bd77d into main Oct 7, 2026
16 of 17 checks passed
@keelerm84
keelerm84 deleted the mk/sdk-3225/encoder-wrap-errors branch October 7, 2026 15:18
@cursor cursor Bot mentioned this pull request Oct 7, 2026
keelerm84 pushed a commit that referenced this pull request Oct 7, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.14.1](v1.14.0...v1.14.1)
(2026-10-07)


### Bug Fixes

* Keep the write error in the chain of Encoder errors
([#81](#81))
([49bd77d](49bd77d))
* **test:** Stop TestServerHandlesLoadsOfPendingTasks deadlocking
([#76](#76))
([d51d9b0](d51d9b0))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.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.

2 participants