Skip to content

fix: prevent data loss in eventbus by applying backpressure#2

Open
AdityaJadhav24 wants to merge 1 commit into
Vyntral:mainfrom
AdityaJadhav24:fix/eventbus-backpressure
Open

fix: prevent data loss in eventbus by applying backpressure#2
AdityaJadhav24 wants to merge 1 commit into
Vyntral:mainfrom
AdityaJadhav24:fix/eventbus-backpressure

Conversation

@AdityaJadhav24
Copy link
Copy Markdown

Description

I identified a logic flaw in the eventbus while auditing the codebase for security tools. The dispatch function in bus.go currently uses a non-blocking select statement with a default case.

The Problem

In many applications, dropping events prevents system crashes, but for a security tool like God's Eye, it causes silent data loss. If the scanner discovers assets faster than a subscriber can process them, the tool increments the dropped counter and throws the data away. This means a user could receive a "complete" report that is actually missing critical findings.

The Fix

I removed the default block in dispatch to ensure the event bus applies backpressure. Instead of dropping data, the publisher will now pause and wait for the buffer to clear. This change guarantees 100% data integrity for every scan.

Testing Updates

  • Removed: TestPublish_NonBlocking_DropsWhenBufferFull. This test is no longer valid because the architecture is no longer designed to drop events.
  • Added: TestPublish_Blocking_AppliesBackpressure. This new test confirms the publisher correctly blocks when the buffer is full and delivers all events once space is available.

Important Tradeoff

By making this change, I am choosing accuracy over raw throughput. If a subscriber is slow, the entire scanning pipeline will slow down to match it. I believe this is the right choice for an auditing tool where missing a single vulnerability is a worse outcome than a longer scan time.

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