Skip to content

Enable Channel Check Linter#4875

Open
mdulin2 wants to merge 18 commits into
wormhole-foundation:mainfrom
mdulin2:channel-check-enable
Open

Enable Channel Check Linter#4875
mdulin2 wants to merge 18 commits into
wormhole-foundation:mainfrom
mdulin2:channel-check-enable

Conversation

@mdulin2

@mdulin2 mdulin2 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

This is part two of integrating the channel linter into the repository. Part one added the custom linter flow, and the channel linter; this enables the channel linter.

In general, three types of changes were made:

  • Made the channel non-blocking by using the WriteToChannelWithoutBlocking helper. Done on errC and metric channel writes mostly.
  • Added ctx.Done() to the select for smoother shutdown.
  • Add nolint:channelcheck with an explanation on why the current setup is correct.

It should be noted that msgC is made as an exception to the channelcheck linter because it should always be a blocking write. With the addition of the nolint linter, we can't add nolint:channelcheck with a comment there. So, I left the original Note on channel capacity comment as is.

@mdulin2
mdulin2 marked this pull request as ready for review July 16, 2026 15:18
@johnsaigle

Copy link
Copy Markdown
Contributor

@mdulin2 looks like this needs a rebase

@mdulin2
mdulin2 force-pushed the channel-check-enable branch from 163170d to 5e25970 Compare July 20, 2026 19:41
@socket-security

socket-security Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedgolang/​golang.org/​x/​tools@​v0.30.075100100100100

View full report

@johnsaigle johnsaigle left a comment

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.

The changes to the channel handling seem sensible. It's also nice to see more detail getting added to the nolint comments 👍🏻

I'm happy to approve after the Near comments are updated.

if msg != nil {
msg.IsReobservation = true
w.msgChan <- msg
w.msgChan <- msg // Note on channel capacity: We never want to drop messages.

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.

Should the changes to this file be nolint instead of the "Note" style?

// If we go back too far, we just report the error and terminate early.
if recursionDepth > maxFallBehindBlocks {
e.eventChan <- EVENT_NEAR_WATCHER_TOO_FAR_BEHIND // Note on channel capacity: Only pauses this watcher
common.WriteToChannelWithoutBlocking(e.eventChan, EVENT_NEAR_WATCHER_TOO_FAR_BEHIND, "near_event_chan") // Non-blocking: eventChan is buffered (cap 10) and metrics-only, so dropping an event is preferable to stalling the watcher.

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.

suggestion: Avoid putting constants directly in documentation in case they change later

Suggested change
common.WriteToChannelWithoutBlocking(e.eventChan, EVENT_NEAR_WATCHER_TOO_FAR_BEHIND, "near_event_chan") // Non-blocking: eventChan is buffered (cap 10) and metrics-only, so dropping an event is preferable to stalling the watcher.
common.WriteToChannelWithoutBlocking(e.eventChan, EVENT_NEAR_WATCHER_TOO_FAR_BEHIND, "near_event_chan") // Non-blocking: eventChan is buffered and metrics-only, so dropping an event is preferable to stalling the watcher.

Same with the cap 10 comment in the other Near file

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.

2 participants