Skip to content

Fix processor stream drain on bounded input - #8

Merged
tmosleyIII merged 1 commit into
mainfrom
bugfix/tmosley/processor-race-conditions
Jun 30, 2026
Merged

Fix processor stream drain on bounded input#8
tmosleyIII merged 1 commit into
mainfrom
bugfix/tmosley/processor-race-conditions

Conversation

@tmosleyIII

Copy link
Copy Markdown
Contributor

This pull request refactors the event processing logic in StandardProcessor to ensure output events are sent before handling input stream EOF, and adds a targeted test for this behavior. The main change is extracting the event processing and sending logic into a dedicated method, improving clarity and correctness when handling stream closure. Additionally, a new test verifies that outputs are sent before the processor returns on input EOF.

Event processing and stream handling improvements:

  • Refactored the main event loop in StandardProcessor.Process by extracting the event processing and response sending logic into a new processAndSend method, ensuring that output events are always sent before the processor returns on input EOF. This change also improves error handling and code readability. [1] [2]
  • Changed the handling of cases where there is no handler or an error occurs during event processing to return nil instead of exiting the goroutine, aligning with the new synchronous processing model.

Testing improvements:

  • Added a new test TestProcessSendsOutputBeforeHandlingInputEOF in processor_test.go to verify that the processor sends output events before returning when the input stream ends. This test uses a fake stream and synchronizes handler execution to ensure correct behavior.

Other:

  • Minor import statement reordering in processor.go for consistency.

@tmosleyIII
tmosleyIII requested a review from Copilot June 30, 2026 18:43
@tmosleyIII
tmosleyIII merged commit a31b95a into main Jun 30, 2026
2 checks passed
@tmosleyIII
tmosleyIII deleted the bugfix/tmosley/processor-race-conditions branch June 30, 2026 19:04
@tmosleyIII
tmosleyIII removed the request for review from Copilot June 30, 2026 19:30
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