test(webkit/window): guard the mock window's fields with a mutex - #47
Conversation
The data race was in the test double, not production. mockWindow.ExecJS appended to execJSCalls with no lock while the test's own goroutine read the same slice, so `go test -race` on display/webkit/pkg/window reported two races on main. Every mockWindow field now sits behind one mutex, reads go through an execJSCallsSnapshot() accessor, and emit/emitFileDrop copy the handler slice outside the lock so a handler that re-enters the mock cannot deadlock. Receipt: GOWORK=off go test -race -count=5 ./display/webkit/pkg/window/ before: 2 × "WARNING: DATA RACE" after: 0 races, ok 2.150s Co-Authored-By: Virgil <virgil@lethean.io>
|
Warning Review limit reached
Next review available in: 40 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The data race
go test -race ./display/webkit/pkg/window/reports onmainis in the test double, not production code.mockWindow.ExecJSappended toexecJSCallsunguarded while the test's goroutine read the same slice.Fix
execJSCallsSnapshot()accessoremit/emitFileDropcopy the handler slice outside the lock, so a handler that re-enters the mock cannot deadlockReceipt
WARNING: DATA RACEok dappco.re/go/render/display/webkit/pkg/window 2.150s🤖 Generated with Claude Code
Co-Authored-By: Virgil virgil@lethean.io