Skip to content

pkg/beholder: add Emitter.Close; track goroutines#1628

Merged
jmank88 merged 1 commit intomainfrom
emitter-close
Oct 21, 2025
Merged

pkg/beholder: add Emitter.Close; track goroutines#1628
jmank88 merged 1 commit intomainfrom
emitter-close

Conversation

@jmank88
Copy link
Copy Markdown
Contributor

@jmank88 jmank88 commented Oct 20, 2025

I noticed that the DualSourceEmitter is launching goroutines without tracking them. This PR extends the interface to implement io.Closer. Alternatively, we could only do that with the concrete types, but we would be trading some no-op boilerplate for opaque casting, so this seems safer.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Oct 20, 2025

⚠️ API Diff Results - Breaking changes detected

📦 Module: github-com-smartcontractkit-chainlink-common

🔴 Breaking Changes (1)

io.Closer (1)
  • Close — ➕ Added

📄 View full apidiff report

Comment thread pkg/beholder/client.go
@jmank88 jmank88 requested a review from pavel-raykov October 21, 2025 15:08
@jmank88 jmank88 marked this pull request as ready for review October 21, 2025 15:08
@jmank88 jmank88 requested review from a team as code owners October 21, 2025 15:08
pavel-raykov
pavel-raykov previously approved these changes Oct 21, 2025
Comment thread pkg/beholder/dual_source_emitter.go Outdated
}

func (d *DualSourceEmitter) Close() error {
close(d.stopCh)
Copy link
Copy Markdown
Contributor

@pkcll pkcll Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to guard against Close being called multiple times to prevent panic here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Close isn't meant to be called more than once, and I would worry about covering that up with a defensive check 🤔 I guess we could return an error

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@jmank88 jmank88 requested review from pavel-raykov and pkcll October 21, 2025 17:54
return errors.New("already closed")
}
close(d.stopCh)
d.wg.Wait()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, waiting first and then closing is probably better to avoid race condition

@jmank88 jmank88 merged commit a50d2a6 into main Oct 21, 2025
19 of 21 checks passed
@jmank88 jmank88 deleted the emitter-close branch October 21, 2025 18:03
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.

4 participants