Skip to content

Wrap Mattermost WebSocket events processing with watchdog and log#674

Draft
hloeung wants to merge 1 commit into
42wim:masterfrom
hloeung:concurrency
Draft

Wrap Mattermost WebSocket events processing with watchdog and log#674
hloeung wants to merge 1 commit into
42wim:masterfrom
hloeung:concurrency

Conversation

@hloeung

@hloeung hloeung commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

This is for receiving of Mattermost events via the WebSocket and processing by matterircd.

#677 is for handling of events and sending IRC messages to clients connect to matterircd.

@hloeung hloeung marked this pull request as draft July 10, 2026 08:32
@hloeung hloeung requested a review from Copilot July 10, 2026 08:33

Copilot AI 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.

Pull request overview

This PR introduces a watchdog wrapper around Mattermost websocket event handling to emit a warning when an individual event handler runs longer than 5 seconds, and ensures the per-worker channel-update ticker is stopped on exit.

Changes:

  • Added executeWithWatchdog to wrap websocket event handler execution with a 5-second warning timer.
  • Routed websocket event handler calls through executeWithWatchdog to standardize long-running handler logging.
  • Stopped the updateChannelsThrottle ticker via defer to avoid leaking ticker resources when workers exit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bridge/mattermost/mattermost.go Outdated
Comment thread bridge/mattermost/mattermost.go Outdated

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread bridge/mattermost/mattermost.go Outdated
Comment on lines +143 to +153
creationStack := debug.Stack()
timer := time.AfterFunc(5*time.Second, func() {
logger.Warnf("CRITICAL WARNING: Worker handling '%s' has been running for >5s! "+
"Event Details: ChannelId=%s, UserId=%s, EventType=%s\n%s",
label,
rawEvent.GetBroadcast().ChannelId,
rawEvent.GetBroadcast().UserId,
rawEvent.EventType(),
string(creationStack),
)
})
@hloeung hloeung changed the title Wrap events processing in a watchdog and log Wrap Mattermost events processing in a watchdog and log Jul 11, 2026
@hloeung hloeung changed the title Wrap Mattermost events processing in a watchdog and log Wrap Mattermost WebSocket events processing with watchdog and log Jul 11, 2026
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