Skip to content

Race in MockProvider mock-message access across overlapping Subscribe goroutines #96

@miotte

Description

@miotte

The package-level mockp is shared across tests in internal/server. MockProvider.Subscribe runs in a goroutine that defers a 500ms sleep before returning, so that goroutine can outlive the test that triggered it. Its read/reset of MockMessages then races against the next test's Subscribe goroutine when -race is enabled.

The slice should be encapsulated behind synchronization (e.g. a sync.Mutex plus SetMockMessages / takeMockMessages helpers) so concurrent tests can't observe or mutate it without coordination.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggoPull requests that update go codetesting

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions