Skip to content

fix(ssestream): synchronize decoder registry - #887

Open
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/ssestream-decoder-registry-race
Open

fix(ssestream): synchronize decoder registry#887
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/ssestream-decoder-registry-race

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

Make the public SSE decoder registry safe for concurrent registration and stream creation.

RegisterDecoder writes the package-level registry while NewDecoder reads it. A focused race test on current main reports a data race and can terminate with fatal error: concurrent map writes.

This change protects registry access with an RWMutex. Decoder lookup copies the factory while holding the read lock, then releases the lock before invoking it.

Fixes #886.

Testing

  • pre-fix go test -race reproduction: data race plus fatal error: concurrent map writes
  • go test -race ./packages/ssestream -count=1: passed on Go 1.26.7
  • SKIP_MOCK_TESTS=true go test ./...: passed on Go 1.26.7
  • ./scripts/check-go-mod: all four modules tidy
  • ./scripts/lint: all analyzer passes reported 0 issues
  • Castiron custom-code budget check: passed
  • git diff --check: passed

No decoder-selection semantics or public API signatures change.

@sylvesterkaczmarek
sylvesterkaczmarek requested a review from a team as a code owner September 4, 2026 12:16
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T12:26:07.792766Z 0312a34 PR opened
🔒 Security Review Completed 2026-09-04T12:19:36.679360Z 0312a34 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

RegisterDecoder races with concurrent stream decoding

1 participant