Skip to content

ValueError: <Token var=<ContextVar name='current_scope' default=None at 0xXXX> at 0xYYY> was created in a different Context #3724

Closed

Description

@arkadiy-telegin

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.12.0

Steps to Reproduce

Noticed the following error in the asyncio integration. It crashes the program. I have the following init:

        sentry_sdk.init(
            dsn=settings.sentry_dsn,
            environment=settings.env,
            integrations=[
                AsyncioIntegration(),
                LoguruIntegration(),
                FastApiIntegration(),
                OpenAIIntegration(),
                RedisIntegration(),
                HttpxIntegration(),
                AioHttpIntegration(),
            ],
            traces_sample_rate=1.0,
            profiles_sample_rate=1.0,
        )

Can it be somehow related to #2908?

Expected Result

No crash.

Actual Result

Traceback (most recent call last):
  File "/venv/lib/python3.11/site-packages/sentry_sdk/integrations/asyncio.py", line 46, in _coro_creating_hub_and_span
    with sentry_sdk.isolation_scope():
  File "/venv/lib/python3.11/site-packages/sentry_sdk/scope.py", line 1628, in isolation_scope
    _current_scope.reset(current_token)
  File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__
    self.gen.throw(typ, value, traceback)
ValueError: <Token var=<ContextVar name='current_scope' default=None at 0x7cc13c5a72e0> at 0x7cc0dc4eb880> was created in a different Context

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Nov 1, 2024
  2. changed the title [-]ValueError: <Token var=<ContextVar name='current_scope' default=None at 0xXXX> at 0xYYY> was created in a different Context[/-] [+]`ValueError: <Token var=<ContextVar name='current_scope' default=None at 0xXXX> at 0xYYY>` was created in a different Context[/+] on Nov 4, 2024
  3. szokeasaurusrex commented on Nov 4, 2024

    @szokeasaurusrex
    Member

    @arkadiy-telegin Could you please provide a Python script which reproduces the error?

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Nov 4, 2024
  5. moved this to Waiting for: Community in GitHub Issues with 👀 3on Nov 4, 2024
  6. getsantry commented on Nov 26, 2024

    @getsantry

    This issue has gone three weeks without activity. In another week, I will close it.

    But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


    "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions