Skip to content

Conversation

@falcon-hayaki
Copy link
Contributor

#83

@xiyaowong
Copy link
Collaborator

???还有人啊

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to fix a silent exit issue in the main process by modifying the reconnection handling logic in the wait() method. The changes restructure the flow to wrap the reconnect_task await in a try-except block and adjust the loop exit condition.

Key Changes

  • Added exception handling around reconnect_task awaiting to prevent unhandled exceptions from propagating
  • Modified the loop exit condition to require both a non-connected state AND no active reconnect task
Comments suppressed due to low confidence (1)

botoy/_internal/client.py:231

  • 'except' clause does nothing but pass and there is no explanatory comment.
                except Exception:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +231 to +232
except Exception:
pass
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bare except Exception: clause silently swallows all exceptions from the reconnect task. This makes debugging difficult and could hide important errors. Consider logging the exception before suppressing it, or at minimum catching more specific exceptions that are expected during reconnection attempts.

Suggested change
except Exception:
pass
except Exception as e:
logger.exception("Exception occurred while awaiting reconnect_task")

Copilot uses AI. Check for mistakes.
await self.reconnect_task
except Exception:
pass
if self.state != "connected" and not self.reconnect_task:
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exit condition logic has changed in a way that could cause premature exit. The original logic would break if reconnect_task was falsy OR if the state wasn't "connected". The new logic only breaks if BOTH conditions are true (state is not "connected" AND no reconnect_task). This means if the state is "disconnected" or "disconnecting" but somehow reconnect_task is truthy, the loop will continue indefinitely. Consider whether this behavior is intentional for the fix.

Suggested change
if self.state != "connected" and not self.reconnect_task:
if self.state != "connected" or not self.reconnect_task:

Copilot uses AI. Check for mistakes.
break
await self.reconnect_task
if self.state != "connected":
if self.reconnect_task:
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reconnect_task attribute is not initialized in the __init__ method. This means if the wait() method is called before any connection attempt that would set reconnect_task in _read_loop, line 228 will raise an AttributeError when checking if self.reconnect_task:. The attribute should be initialized to None in the constructor.

Copilot uses AI. Check for mistakes.
@falcon-hayaki
Copy link
Contributor Author

???还有人啊

因为丢server里一直能run就没管
最近服务器要迁移顺便上来看看啥情况 发现一年没动过了(

@HeiLAAS
Copy link
Contributor

HeiLAAS commented Dec 19, 2025

lemon哥,修复一下吧。大伙都在呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants