[PR #93] refactor(retry): remove sleep-based waits from websocket and peer tes… #463

Open
opened 2026-04-25 02:00:06 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fosrl/olm/pull/93
Author: @LaurenceJJones
Created: 2/11/2026
Status: 🔄 Open

Base: mainHead: remove-time-sleep-functions


📝 Commits (1)

  • b71d2a9 refactor(retry): remove sleep-based waits from websocket and peer test loops

📊 Changes

2 files changed (+84 additions, -84 deletions)

View changed files

📝 peers/monitor/wgtester.go (+51 -48)
📝 websocket/client.go (+33 -36)

📄 Description

…t loops

Community Contribution License Agreement

By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.

Description

I dont know if time.sleep was chosen for a reason, but this function blocks the function in which it is invoked, these for loops are context aware meaning if context is cancelled we should be responsive to this information. Using a ticker instead means we can use a select statement where we wait for either ticker or the context cancellation.

  • websocket/client: replace connectWithRetry sleep loop with timer-driven retry that can exit immediately on done
  • peers/monitor/wgtester: refactor TestPeerConnection to a straight happy path and replace timeout sleep with context-aware wait
  • keep retry/backoff behavior unchanged while improving shutdown/cancel responsiveness

How to test?

Tough as more a refactor, but when context is cancelled each timeout should respect the context as using time.sleep function blocks the goroutine meaning responsiveness to the cancellation is delayed.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/fosrl/olm/pull/93 **Author:** [@LaurenceJJones](https://github.com/LaurenceJJones) **Created:** 2/11/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `remove-time-sleep-functions` --- ### 📝 Commits (1) - [`b71d2a9`](https://github.com/fosrl/olm/commit/b71d2a9c51a15c007440172b07e294a654315eec) refactor(retry): remove sleep-based waits from websocket and peer test loops ### 📊 Changes **2 files changed** (+84 additions, -84 deletions) <details> <summary>View changed files</summary> 📝 `peers/monitor/wgtester.go` (+51 -48) 📝 `websocket/client.go` (+33 -36) </details> ### 📄 Description …t loops ## Community Contribution License Agreement By creating this pull request, I grant the project maintainers an unlimited, perpetual license to use, modify, and redistribute these contributions under any terms they choose, including both the AGPLv3 and the Fossorial Commercial license terms. I represent that I have the right to grant this license for all contributed content. ## Description I dont know if `time.sleep` was chosen for a reason, but this function blocks the function in which it is invoked, these for loops are context aware meaning if context is cancelled we should be responsive to this information. Using a ticker instead means we can use a select statement where we wait for either ticker or the context cancellation. - websocket/client: replace connectWithRetry sleep loop with timer-driven retry that can exit immediately on done - peers/monitor/wgtester: refactor TestPeerConnection to a straight happy path and replace timeout sleep with context-aware wait - keep retry/backoff behavior unchanged while improving shutdown/cancel responsiveness ## How to test? Tough as more a refactor, but when context is cancelled each timeout should respect the context as using `time.sleep` function blocks the goroutine meaning responsiveness to the cancellation is delayed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-25 02:00:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/olm#463