Skip to content

Implement IDisposable on stream readers/writers#233

Merged
MaxHeimbrock merged 2 commits intomainfrom
max/claude/fix-stream-disposable
Apr 10, 2026
Merged

Implement IDisposable on stream readers/writers#233
MaxHeimbrock merged 2 commits intomainfrom
max/claude/fix-stream-disposable

Conversation

@MaxHeimbrock
Copy link
Copy Markdown
Contributor

Background

TextStreamReader, ByteStreamReader, TextStreamWriter, and ByteStreamWriter hold native FFI handles but never implement IDisposable. If a stream is abandoned without completing (e.g., no handler registered, or user drops the object mid-stream), the native handle leaks. This also resolves the TODO comments in Room.cs about disposing unhandled stream readers.

Changes

  • Add IDisposable to all four stream reader/writer classes in DataStream.cs
  • Add ObjectDisposedException guards to all public methods (ReadAll, ReadIncremental, WriteToFile, Write, Close)
  • Dispose unhandled stream readers in Room.cs when no handler is registered for the stream's topic

🤖 Generated with Claude Code

MaxHeimbrock and others added 2 commits April 9, 2026 14:37
… streams

TextStreamReader, ByteStreamReader, TextStreamWriter, and ByteStreamWriter
now implement IDisposable to properly release their native FFI handles.
Public methods throw ObjectDisposedException after disposal.

Room.cs now disposes stream readers when no handler is registered for
their topic, fixing the native handle leak noted in the TODOs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MaxHeimbrock MaxHeimbrock merged commit 2a7c57d into main Apr 10, 2026
20 of 21 checks passed
@MaxHeimbrock MaxHeimbrock deleted the max/claude/fix-stream-disposable branch April 10, 2026 15:14
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