Skip to content
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

💅 Propagate error causes via asyncio protocols #8089

Merged

Conversation

webknjaz
Copy link
Member

@webknjaz webknjaz commented Jan 29, 2024

This is supposed to unify setting exceptions on the future objects, allowing to also attach their causes whenever available.

It's also supposed to help with tracking down what's happening with #4581.

What do these changes do?

$sbj.

Are there changes in behavior for the user?

They should be able to see more detailed tracebacks.

Related issue number

#4581

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES/ folder
    • name it <issue_or_pr_num>.<type>.rst (e.g. 588.bugfix.rst)

    • if you don't have an issue number, change it to the pull request
      number after creating the PR

      • .bugfix: A bug fix for something the maintainers deemed an
        improper undesired behavior that got corrected to match
        pre-agreed expectations.
      • .feature: A new behavior, public APIs. That sort of stuff.
      • .deprecation: A declaration of future API removals and breaking
        changes in behavior.
      • .breaking: When something public is removed in a breaking way.
        Could be deprecated in an earlier release.
      • .doc: Notable updates to the documentation structure or build
        process.
      • .packaging: Notes for downstreams about unobvious side effects
        and tooling. Changes in the test invocation considerations and
        runtime assumptions.
      • .contrib: Stuff that affects the contributor experience. e.g.
        Running tests, building the docs, setting up the development
        environment.
      • .misc: Changes that are hard to assign to any of the above
        categories.
    • Make sure to use full sentences with correct case and punctuation,
      for example:

      Fixed issue with non-ascii contents in doctest text files
      -- by :user:`contributor-gh-handle`.

      Use the past tense or the present tense a non-imperative mood,
      referring to what's changed compared to the last released version
      of this project.

@webknjaz webknjaz added enhancement client server backport-3.9 Trigger automatic backporting to the 3.9 release branch by Patchback robot backport-3.10 Trigger automatic backporting to the 3.10 release branch by Patchback robot labels Jan 29, 2024
aiohttp/client_proto.py Dismissed Show dismissed Hide dismissed
aiohttp/http_parser.py Dismissed Show dismissed Hide dismissed
@webknjaz
Copy link
Member Author

@bdraco @Dreamsorcerer please, consider this idea 🙏 Hopefully, it's viable.

I expect that this needs polishing, of course. Especially since I didn't even bother touching the tests. Surprisingly, only 6 failed: https://github.com/aio-libs/aiohttp/actions/runs/7691292578/job/20956384838?pr=8089#step:11:3813.

aiohttp/client_proto.py Outdated Show resolved Hide resolved
aiohttp/client_proto.py Outdated Show resolved Hide resolved
aiohttp/client_reqrep.py Outdated Show resolved Hide resolved
@webknjaz webknjaz force-pushed the features/4581-protocol-error-propagation branch from 41f7b1a to 6c4278c Compare January 29, 2024 05:03
aiohttp/streams.py Outdated Show resolved Hide resolved
aiohttp/helpers.py Outdated Show resolved Hide resolved
aiohttp/client_proto.py Outdated Show resolved Hide resolved
aiohttp/client_proto.py Outdated Show resolved Hide resolved
aiohttp/helpers.py Outdated Show resolved Hide resolved
aiohttp/helpers.py Outdated Show resolved Hide resolved
aiohttp/http_parser.py Outdated Show resolved Hide resolved
aiohttp/http_parser.py Outdated Show resolved Hide resolved
aiohttp/streams.py Outdated Show resolved Hide resolved
aiohttp/streams.py Outdated Show resolved Hide resolved
aiohttp/streams.py Outdated Show resolved Hide resolved
aiohttp/streams.py Outdated Show resolved Hide resolved
@webknjaz webknjaz force-pushed the features/4581-protocol-error-propagation branch from f0d5b92 to 3706e7c Compare February 16, 2024 03:25
@webknjaz webknjaz enabled auto-merge (squash) February 16, 2024 03:30
@webknjaz webknjaz merged commit dc38630 into aio-libs:master Feb 16, 2024
28 of 32 checks passed
Copy link
Contributor

patchback bot commented Feb 16, 2024

Backport to 3.9: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply dc38630 on top of patchback/backports/3.9/dc38630b168a169139974617d75e176530c91696/pr-8089

Backporting merged PR #8089 into master

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/aio-libs/aiohttp.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/3.9/dc38630b168a169139974617d75e176530c91696/pr-8089 upstream/3.9
  4. Now, cherry-pick PR 💅 Propagate error causes via asyncio protocols #8089 contents into that branch:
    $ git cherry-pick -x dc38630b168a169139974617d75e176530c91696
    If it'll yell at you with something like fatal: Commit dc38630b168a169139974617d75e176530c91696 is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x dc38630b168a169139974617d75e176530c91696
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR 💅 Propagate error causes via asyncio protocols #8089 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/3.9/dc38630b168a169139974617d75e176530c91696/pr-8089
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

Copy link
Contributor

patchback bot commented Feb 16, 2024

Backport to 3.10: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply dc38630 on top of patchback/backports/3.10/dc38630b168a169139974617d75e176530c91696/pr-8089

Backporting merged PR #8089 into master

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/aio-libs/aiohttp.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/3.10/dc38630b168a169139974617d75e176530c91696/pr-8089 upstream/3.10
  4. Now, cherry-pick PR 💅 Propagate error causes via asyncio protocols #8089 contents into that branch:
    $ git cherry-pick -x dc38630b168a169139974617d75e176530c91696
    If it'll yell at you with something like fatal: Commit dc38630b168a169139974617d75e176530c91696 is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x dc38630b168a169139974617d75e176530c91696
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR 💅 Propagate error causes via asyncio protocols #8089 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/3.10/dc38630b168a169139974617d75e176530c91696/pr-8089
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

webknjaz added a commit to webknjaz/aiohttp that referenced this pull request Feb 16, 2024
…ia asyncio protocols

This is supposed to unify setting exceptions on the future objects,
allowing to also attach their causes whenever available. It'll make
possible for the end-users to see more detailed tracebacks.

It's also supposed to help with tracking down what's happening
with aio-libs#4581.

PR aio-libs#8089

Co-Authored-By: J. Nick Koston <nick@koston.org>
Co-Authored-By: Sam Bull <aa6bs0@sambull.org>
(cherry picked from commit dc38630)
webknjaz added a commit to webknjaz/aiohttp that referenced this pull request Feb 16, 2024
…ia asyncio protocols

This is supposed to unify setting exceptions on the future objects,
allowing to also attach their causes whenever available. It'll make
possible for the end-users to see more detailed tracebacks.

It's also supposed to help with tracking down what's happening
with aio-libs#4581.

PR aio-libs#8089

Co-Authored-By: J. Nick Koston <nick@koston.org>
Co-Authored-By: Sam Bull <aa6bs0@sambull.org>
(cherry picked from commit dc38630)
webknjaz added a commit to webknjaz/aiohttp that referenced this pull request Feb 16, 2024
…a asyncio protocols

This is supposed to unify setting exceptions on the future objects,
allowing to also attach their causes whenever available. It'll make
possible for the end-users to see more detailed tracebacks.

It's also supposed to help with tracking down what's happening
with aio-libs#4581.

PR aio-libs#8089

Co-Authored-By: J. Nick Koston <nick@koston.org>
Co-Authored-By: Sam Bull <aa6bs0@sambull.org>
(cherry picked from commit dc38630)
webknjaz added a commit to webknjaz/aiohttp that referenced this pull request Feb 16, 2024
…a asyncio protocols

This is supposed to unify setting exceptions on the future objects,
allowing to also attach their causes whenever available. It'll make
possible for the end-users to see more detailed tracebacks.

It's also supposed to help with tracking down what's happening
with aio-libs#4581.

PR aio-libs#8089

Co-Authored-By: J. Nick Koston <nick@koston.org>
Co-Authored-By: Sam Bull <aa6bs0@sambull.org>
(cherry picked from commit dc38630)
webknjaz added a commit to webknjaz/aiohttp that referenced this pull request Feb 16, 2024
…ia asyncio protocols

This is supposed to unify setting exceptions on the future objects,
allowing to also attach their causes whenever available. It'll make
possible for the end-users to see more detailed tracebacks.

It's also supposed to help with tracking down what's happening
with aio-libs#4581.

PR aio-libs#8089

Co-Authored-By: J. Nick Koston <nick@koston.org>
Co-Authored-By: Sam Bull <aa6bs0@sambull.org>
(cherry picked from commit dc38630)
webknjaz added a commit that referenced this pull request Feb 16, 2024
…o protocols (#8162)

**This is a backport of PR #8089 as merged into master
(dc38630).**

This is supposed to unify setting exceptions on the future objects,
allowing to also attach their causes whenever available. It'll make
possible for the end-users to see more detailed tracebacks.

It's also supposed to help with tracking down what's happening with
#4581.

PR #8089

Co-Authored-By: J. Nick Koston <nick@koston.org>
Co-Authored-By: Sam Bull <aa6bs0@sambull.org>
(cherry picked from commit dc38630)
webknjaz added a commit that referenced this pull request Feb 16, 2024
…io protocols (#8161)

**This is a backport of PR #8089 as merged into master
(dc38630).**

This is supposed to unify setting exceptions on the future objects,
allowing to also attach their causes whenever available. It'll make
possible for the end-users to see more detailed tracebacks.

It's also supposed to help with tracking down what's happening with
#4581.

PR #8089

Co-Authored-By: J. Nick Koston <nick@koston.org>
Co-Authored-By: Sam Bull <aa6bs0@sambull.org>
(cherry picked from commit dc38630)
@webknjaz
Copy link
Member Author

@bdraco I'm triggering a release candidate via https://github.com/aio-libs/aiohttp/actions/runs/7926204466 — you'll be able to deploy this pre-release for testing before cutting a stable version.

@webknjaz
Copy link
Member Author

@bdraco I ended up having to re-trigger the release on another commit: https://github.com/aio-libs/aiohttp/actions/runs/7930478394/job/21655287776.

It's now available via https://pypi.org/project/aiohttp/3.9.4rc0/.

cc @Dreamsorcerer FYI

bdraco added a commit to home-assistant/supervisor that referenced this pull request Feb 16, 2024
This PR is rc0 for now but will be updated when the full release it out. For now its to get a CI run to see if there are any side effects/regressions and make sure aio-libs/aiohttp#8089 is good with our code.
@bdraco
Copy link
Member

bdraco commented Feb 16, 2024

Running HA supervisor and core CIs against this now.

I'm also going to test it on my production systems shortly

@webknjaz
Copy link
Member Author

I'm also deploying this into the Chronographer and Patchback bots now, that have Sentry hooked up. This should help with figuring out #4581 since Sentry alerts with that arrive every day and it's quite annoying.

@bdraco
Copy link
Member

bdraco commented Feb 16, 2024

I had to revert back right away when testing on production due to:

2024-02-16 09:45:14.978 ERROR (MainThread) [pyunifiprotect.websocket] Websocket disconnect error: %s
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pyunifiprotect/websocket.py", line 95, in _websocket_loop
    self._ws_connection = await session.ws_connect(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 884, in _ws_connect
    resp = await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 472, in _request
    raise NonHttpUrlClientError(url)
aiohttp.client_exceptions.NonHttpUrlClientError: wss://192.168.209.164/proxy/protect/ws/updates?lastUpdateId=80f54055-84de-4e15-95d7-80cac46aafbd

@Dreamsorcerer
Copy link
Member

I had to revert back right away when testing on production due to:

I thought that PR was only merged into 3.10?

@bdraco
Copy link
Member

bdraco commented Feb 16, 2024

I had to revert back right away when testing on production due to:

I thought that PR was only merged into 3.10?

It did. Sorry for the lack of clarity. I pulled 3.10 on to test since that's what I've been running with as the staging production env is making use of 3.10 features. I'm going to pull it back down to 3.9 later today when I have free cycles

@bdraco
Copy link
Member

bdraco commented Feb 16, 2024

I've managed to get the smaller one downgraded to 3.9 (3.9.4rc0). So far so good.

I'm working on the larger one

@bdraco
Copy link
Member

bdraco commented Feb 16, 2024

Larger install is working well. No regressions observed. I'm about to leave town for the weekend. I'll report back after checking the logs when I get back home (Sunday night/Monday depending on jetlag)

@webknjaz
Copy link
Member Author

Great! I hope I'll get some tracebacks from the bots too, maybe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-3.9 Trigger automatic backporting to the 3.9 release branch by Patchback robot backport-3.10 Trigger automatic backporting to the 3.10 release branch by Patchback robot bot:chronographer:provided There is a change note present in this PR client enhancement server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants