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

socket.gaierror during (re)connection is unhandled #2407

Closed
dgw opened this issue Feb 1, 2023 · 1 comment · Fixed by #2430
Closed

socket.gaierror during (re)connection is unhandled #2407

dgw opened this issue Feb 1, 2023 · 1 comment · Fixed by #2430
Labels
Bug Things to squish; generally used for issues Core/Networking
Milestone

Comments

@dgw
Copy link
Member

dgw commented Feb 1, 2023

Description

Running a Sopel instance from my laptop while traveling, the power (and therefore Starlink) at our rental cut out overnight.

Sopel failed to reconnect because of an unhandled error case related to DNS, and quit itself completely.

Reproduction steps

  1. Start Sopel normally and wait for it to connect
  2. Disrupt network connection
    a. If on Wi-Fi, I believe cutting power to the AP would emulate what happened to me

Expected behavior

Sopel should catch any socket.gaierror exception and queue another connection attempt.

Relevant logs

[2023-02-01 04:05:03,340] sopel.cli.run        WARNING  - Disconnected. Reconnecting in 20 seconds...
[2023-02-01 04:05:23,350] sopel.bot            INFO     - Loading plugins...
    <snip, irrelevant noise>
[2023-02-01 04:05:23,463] sopel.bot            INFO     - Plugin loaded: coretasks
[2023-02-01 04:05:23,464] sopel.bot            INFO     - Registered 3 plugins, 0 failed, 55 disabled
[2023-02-01 04:05:39,432] sopel.irc.backends   ERROR    - Unable to connect.
Traceback (most recent call last):
  File "/home/dgw/github/sopel/sopel/irc/backends.py", line 391, in _run_forever
    self._reader, self._writer = await asyncio.open_connection(
  File "/usr/lib/python3.9/asyncio/streams.py", line 52, in open_connection
    transport, _ = await loop.create_connection(
  File "/usr/lib/python3.9/asyncio/base_events.py", line 1017, in create_connection
    infos = await self._ensure_resolved(
  File "/usr/lib/python3.9/asyncio/base_events.py", line 1396, in _ensure_resolved
    return await loop.getaddrinfo(host, port, family=family, type=type,
  File "/usr/lib/python3.9/asyncio/base_events.py", line 856, in getaddrinfo
    return await self.run_in_executor(
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.9/socket.py", line 953, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution
[2023-02-01 04:05:39,603] sopel.irc.backends   INFO     - Connection backend stopped.
[2023-02-01 04:05:39,603] sopel.bot            INFO     - Shutting down
[2023-02-01 04:05:39,604] sopel.bot            INFO     - Stopping the Job Scheduler.
[2023-02-01 04:05:40,479] sopel.bot            INFO     - Job Scheduler stopped.
[2023-02-01 04:05:40,479] sopel.bot            INFO     - Calling shutdown for 2 plugins.

Notes

Past mentions of gaierror in our issue tracker are mostly about the ip & wikipedia plugins. I'm surprised it never came up for core, outside of one thread about IPv6.

Sopel version

f527b13

Installation method

pip install

Python version

3.9.5

Operating system

Ubuntu 20.04 (WSL 1)

IRCd

No response

Relevant plugins

No response

@dgw dgw added Bug Things to squish; generally used for issues Needs Triage Issues that need to be reviewed and categorized labels Feb 1, 2023
@dgw dgw added this to the 8.0.0 milestone May 2, 2023
@dgw dgw removed the Needs Triage Issues that need to be reviewed and categorized label May 29, 2023
@dgw dgw linked a pull request May 29, 2023 that will close this issue
4 tasks
@dgw
Copy link
Member Author

dgw commented May 29, 2023

Handling of socket.gaierror was added in #2430.

@dgw dgw closed this as completed May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Things to squish; generally used for issues Core/Networking
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant