Repository navigation
Fix 'asyncio.CancelledError' capturing for 'AioHttpIntegration' #571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| import asyncio | ||
| import json | ||
| from contextlib import suppress | ||
|
|
||
| from aiohttp import web | ||
| from aiohttp.client import ServerDisconnectedError | ||
|
|
||
| from sentry_sdk.integrations.aiohttp import AioHttpIntegration | ||
|
|
||
|
|
@@ -120,6 +123,28 @@ async def hello(request): | |
| assert not events | ||
|
|
||
|
|
||
| async def test_cancelled_error_not_captured( | ||
| sentry_init, aiohttp_client, loop, capture_events | ||
| ): | ||
| sentry_init(integrations=[AioHttpIntegration()]) | ||
|
|
||
| async def hello(request): | ||
| raise asyncio.CancelledError() | ||
|
|
||
| app = web.Application() | ||
| app.router.add_get("/", hello) | ||
|
|
||
| events = capture_events() | ||
| client = await aiohttp_client(app) | ||
|
|
||
| with suppress(ServerDisconnectedError): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've used At the moment, But, if you'd like to use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, let's stick with this |
||
| # Intended `aiohttp` interaction: server will disconnect if it | ||
| # encounters `asyncio.CancelledError` | ||
| await client.get("/") | ||
|
|
||
| assert not events | ||
|
|
||
|
|
||
| async def test_half_initialized(sentry_init, aiohttp_client, loop, capture_events): | ||
| sentry_init(integrations=[AioHttpIntegration()]) | ||
| sentry_init() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.