Skip to content

Hub::configure_scope can lose concurrent updates on a shared Hub #1110

Closed

Description

@szokeasaurusrex

Hub::configure_scope clones the current scope under a read lock, invokes the callback on the clone, then replaces the current scope under a later write lock. Two concurrent calls on the same shared Hub can therefore clone the same initial scope, and the later replacement can discard the earlier mutation.

This is a correctness issue for shared Hub instances: concurrent scope modifications can result in data loss when independent mutations are made to the same shared scope.

Expected behavior: concurrent configure_scope calls on the same Hub should apply mutations atomically with respect to each other, or the API documentation should state that concurrent updates may overwrite each other. One possible fix is to run the scope mutation while holding the write lock, for example through with_current_scope_mut; the implementation should account for the existing constraint that calling scope-related Sentry APIs from inside the callback is unsupported and may panic.

Activity

  1. linear-code commented on May 5, 2026

    @linear-code
  2. added
    Rust
    Bug
    on May 5, 2026
  3. added
    Bug
    and removed
    Bug
    on Jul 16, 2026
  4. szokeasaurusrex commented on Aug 4, 2026

    @szokeasaurusrex
    MemberAuthor

    This actually seems like a documentation issue. The issue was originally discovered by Claude, but it seems that we already state in the crate-level docs that using Hubs concurrently "may lead to unexpected results up to panics."

    I am therefore treating this as a docs issue and adding some docs on the Hub and the configure_scope method to clarify that concurrent use of hubs, although safe, is not recommended.

  5. added and removed
    Bug
    on Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions