Skip to content

fix: race condition in IdeStreamingSink #4857

@thomhurst

Description

@thomhurst

Description

IdeStreamingSink.cs (Lines 147-152)

Double-check locking pattern without proper synchronization:

if (state.IsCompleted || testContext.Result is not null) { state.TryMarkCompleted(); return; }
// ... Send update
if (state.IsCompleted || testContext.Result is not null) { state.TryMarkCompleted(); return; }

Between the first check and sending the update, another thread could mark the test as completed, resulting in state updates being sent after test completion. This could cause IDE test explorers to receive updates after seeing the final state, causing UI glitches.

Timer Leak (Lines 80-85)

Timer is created with new Timer() but if an exception occurs during CreateStreamingState, the timer could leak. Dispose() is only called in CleanupTest().

Suggested Fix

  • Use a single atomic check: if (!state.TryMarkCompleted()) return;
  • Wrap state creation in try-catch and always dispose the timer on failure

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions