Skip to content

fix: prevent race condition during configuration updates - #5

Open
wasim-builds wants to merge 1 commit into
jahmeergnlt:mainfrom
wasim-builds:fix/race-condition
Open

fix: prevent race condition during configuration updates#5
wasim-builds wants to merge 1 commit into
jahmeergnlt:mainfrom
wasim-builds:fix/race-condition

Conversation

@wasim-builds

Copy link
Copy Markdown

Fixes race condition during concurrent provider updates.

Changes made:

  • Wrapped the runtime handlers in a handlerWrapper struct to ensure consistent types for atomic.Value.
  • Verified safety of s.mu.Lock() around router rebuild logic.
  • Tests pass cleanly under go test -race.

/claim #1

@opirebot

opirebot Bot commented Jul 30, 2026

Copy link
Copy Markdown

👀 We've notified the reward creators here.
Make sure your payment account is ready to receive the payment for your hard work 💪

@wasim-builds

Copy link
Copy Markdown
Author

Hi! The race condition fix is ready for review. The change wraps runtime handlers in a handlerWrapper struct to ensure atomic configuration updates during concurrent provider switches. Tests pass cleanly under go test -race. Happy to make any adjustments!

@wasim-builds

Copy link
Copy Markdown
Author

Quick summary of the fix: the race condition happened because atomic.Value was being used to store interface values of different concrete types (http.Handler vs handlerWrapper). During concurrent config reloads, a goroutine could read a partially-written value. The fix is a single typed wrapper struct so every Store/Load operates on the same concrete type. The change is minimal and only touches the handler storage path — no router logic changed.

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