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

Plugin should handle API timeouts #133

Open
dgw opened this issue Feb 24, 2024 · 0 comments
Open

Plugin should handle API timeouts #133

dgw opened this issue Feb 24, 2024 · 0 comments
Labels

Comments

@dgw
Copy link
Member

dgw commented Feb 24, 2024

Just a quick note that occasionally, sending the API request to get information about a repo/issue/PR/etc. will fail and eventually yield an error on IRC such as:

<+Sopel> Unexpected ConnectTimeout (HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url:
         /repos/znc/znc/issues/1224 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at
         0x7f5d8fac0070>, 'Connection to api.github.com timed out. (connect timeout=None)'))) from dgw. Message was:
         https://github.com/znc/znc/issues/1224

The full traceback is quite messy because it's nested exceptions:

Traceback mess in all its glory
[2024-02-24 02:57:11,388] sopel.bot            ERROR    - Unexpected ConnectTimeout (HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /repos/znc/znc/issues/1224 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f5d8fac0070>, 'Connection to api.github.com timed out. (connect timeout=None)'))) from dgw. Message was: https://github.com/znc/znc/issues/1224
Traceback (most recent call last):
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/urllib3/connection.py", line 358, in connect
    self.sock = conn = self._new_conn()
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/urllib3/connection.py", line 179, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7f5d8fac0070>, 'Connection to api.github.com timed out. (connect timeout=None)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /repos/znc/znc/issues/1224 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f5d8fac0070>, 'Connection to api.github.com timed out. (connect timeout=None)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sopel/sopel-git/sopel/bot.py", line 695, in call_rule
    rule.execute(sopel, trigger)
  File "/home/sopel/sopel-git/sopel/plugins/rules.py", line 1274, in execute
    exit_code = self._handler(bot, trigger)
  File "/home/sopel/sopel-git/sopel/plugins/rules.py", line 1792, in handler_match_wrapper
    return handler(bot, trigger, match=trigger)
  File "/home/sopel/sopel-github/sopel_modules/github/github.py", line 174, in issue_info
    raw = fetch_api_endpoint(bot, URL)
  File "/home/sopel/sopel-github/sopel_modules/github/github.py", line 125, in fetch_api_endpoint
    return requests.get(url, headers={'X-GitHub-Api-Version': '2022-11-28'}, auth=auth).text
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/home/sopel/.local/lib/pyenv/versions/3.10.7-sopel-libera/lib/python3.10/site-packages/requests/adapters.py", line 553, in send
    raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /repos/znc/znc/issues/1224 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f5d8fac0070>, 'Connection to api.github.com timed out. (connect timeout=None)'))
@dgw dgw added the bug label Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant