fix: Client retry logic, redundant listener set#233
fix: Client retry logic, redundant listener set#233nekomeowww merged 7 commits intomoeru-ai:mainfrom
Conversation
✅ Deploy Preview for airi-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for airi-vtuber ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Summary of Changes
Hello @Mirza-Samad-Ahmed-Baig, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request focuses on enhancing the stability, cleanliness, and dependency management of the client-side SDK. It addresses critical issues related to the client's retry mechanism, removes unnecessary code, and ensures all required packages are properly declared, leading to a more robust and maintainable codebase.
Highlights
- Client Stability: Corrected a logical error in the
retryWithExponentialBackofffunction withinpackages/server-sdk/src/client.ts. Theattempts++increment was changed toattempts + 1in the recursive call, ensuring the exponential backoff mechanism functions as intended and preventing infinite retry loops, thereby improving connection reliability. - Code Cleanliness: Removed a redundant
this.eventListeners.set(event, listeners)line from theonEventmethod inpackages/server-sdk/src/client.ts. This change eliminates unnecessary code, making the event listener management slightly leaner and clearer. - Dependency Management: Explicitly added
@moeru/stdandcrosswsto thedevDependenciessection of the rootpackage.json. This addresses previously missing dependency declarations, ensuring all required packages are properly listed and preventing potential build or runtime issues in fresh environments.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request correctly fixes a retry logic bug that caused an infinite loop and removes a redundant line of code, improving maintainability.
However, the approach to fixing missing dependencies by adding them to the root package.json is not ideal for a monorepo. I've left a comment suggesting that these dependencies should be declared within the specific workspace package that uses them to ensure proper dependency encapsulation and project structure.
The other changes are solid improvements.
| "vitest": "^3.2.4", | ||
| "@moeru/std": "^0.0.1", | ||
| "crossws": "^0.0.1" |
There was a problem hiding this comment.
These dependencies, @moeru/std and crossws, are specific to the @proj-airi/server-sdk package. In a pnpm workspace monorepo, dependencies should be declared in the package.json of the package that uses them, not in the root package.json.
Adding them to the root devDependencies can:
- Obscure the true dependencies of individual packages.
- Cause issues if a package is built, tested, or published in isolation.
- Lead to dependency management confusion.
Please remove these dependencies from the root package.json and ensure they are correctly listed in packages/server-sdk/package.json. Based on their usage (sleep and WebSocket), they should be listed in the dependencies section of that package.
"vitest": "^3.2.4"
This pull request addresses several issues identified through static analysis and code review within the airi project, primarily focusing on the packages/server-sdk and package.json files.
Problem:
counter was incremented post-call (attempts++), leading to an infinite loop of retries instead of an exponential backoff.
line was redundant as listeners was already a reference to the array in the map. While not a critical error, it's unnecessary code.
packages/server-sdk/src/client.ts. This could lead to build failures or runtime errors in fresh environments.
uses pydantic.v1 while the pyproject.toml specifies Pydantic v2. This is noted as a potential future compatibility issue.
Solution:
attempts counter was incremented post-call (attempts++), leading to an infinite loop of retries instead of an exponential backoff.
packages/server-sdk/src/client.ts to ensure correct exponential backoff behavior.
packages/server-sdk/src/client.ts.
required packages are declared.
potential migration or explicit pinning.
Benefits:
build/runtime issues for new contributors or deployments.