Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-17452.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- fix(dashboard): drain review-question autodecide sweep before WS test cleanup (#17452)
3 changes: 3 additions & 0 deletions src/pkg/dashboard/contribute_ws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ func setupWSTest(t *testing.T) (*Server, *httptest.Server) {
t.Cleanup(func() { taskLedgerPersistenceEnabled = oldLedgerPersistence })

s := NewServer(0, slog.Default())
// Registered after the redirect so it runs first: a status publish starts a
// background review-question sweep that reads the redirected globals.
t.Cleanup(s.reviewQuestionAuto.wg.Wait)
s.registerContributeRoutes()
// Registered BEFORE the Close cleanup (cleanups run LIFO) so the order at
// teardown is: hub Close, then wait for every HandleWS to unwind, and only
Expand Down
13 changes: 9 additions & 4 deletions src/pkg/dashboard/review_question_autodecide.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ type reviewQuestionAutodecideMarker struct {
type reviewQuestionAutodecide struct {
mu sync.Mutex
running bool
lastAt time.Time
path string
loaded bool
items map[string]reviewQuestionAutodecideMarker
// wg tracks the background sweep so tests can drain it before restoring
// the package globals the sweep reads.
wg sync.WaitGroup
lastAt time.Time
path string
loaded bool
items map[string]reviewQuestionAutodecideMarker
}

func (st *reviewQuestionAutodecide) filePath() string {
Expand Down Expand Up @@ -291,7 +294,9 @@ func (s *Server) maybeAutoDecideReviewQuestions(status *StatusPayload, now time.
if s.deps.Ctx != nil {
ctx = s.deps.Ctx
}
st.wg.Add(1)
go func() {
defer st.wg.Done()
defer func() {
st.mu.Lock()
st.running = false
Expand Down
Loading