Skip to content

fix: Client retry logic, redundant listener set#233

Merged
nekomeowww merged 7 commits intomoeru-ai:mainfrom
Mirza-Samad-Ahmed-Baig:main
Jun 28, 2025
Merged

fix: Client retry logic, redundant listener set#233
nekomeowww merged 7 commits intomoeru-ai:mainfrom
Mirza-Samad-Ahmed-Baig:main

Conversation

@Mirza-Samad-Ahmed-Baig
Copy link
Copy Markdown
Contributor

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:

  1. Incorrect Retry Logic: The retryWithExponentialBackoff function in packages/server-sdk/src/client.ts had a logical error where the attempts
    counter was incremented post-call (attempts++), leading to an infinite loop of retries instead of an exponential backoff.
  2. Redundant Listener Management: In the onEvent method within packages/server-sdk/src/client.ts, the this.eventListeners.set(event, listeners)
    line was redundant as listeners was already a reference to the array in the map. While not a critical error, it's unnecessary code.
  3. Missing Dependencies: The package.json file was missing explicit declarations for @moeru/std and crossws, which are imported and used in
    packages/server-sdk/src/client.ts. This could lead to build failures or runtime errors in fresh environments.
  4. Pydantic Version Discrepancy (Informational): The vlm_mamba/model.py file (from a previous task, but relevant for overall project health)
    uses pydantic.v1 while the pyproject.toml specifies Pydantic v2. This is noted as a potential future compatibility issue.

Solution:

  1. Incorrect Retry Logic: The retryWithExponentialBackoff function in packages/server-sdk/src/client.ts had a logical error where the
    attempts counter was incremented post-call (attempts++), leading to an infinite loop of retries instead of an exponential backoff.
  2. Corrected Retry Logic: Changed attempts++ to attempts + 1 in the recursive call within retryWithExponentialBackoff in
    packages/server-sdk/src/client.ts to ensure correct exponential backoff behavior.
  3. Removed Redundant Listener Set: Eliminated the redundant this.eventListeners.set(event, listeners) line in the onEvent method of
    packages/server-sdk/src/client.ts.
  4. Added Missing Dependencies: Explicitly added @moeru/std and crossws to the devDependencies section of the root package.json to ensure all
    required packages are declared.
  5. Pydantic Version Comment: Added an inline comment to vlm_mamba/model.py to highlight the Pydantic version discrepancy, advising on
    potential migration or explicit pinning.

Benefits:

  • Increased Stability: The client's retry mechanism will now function as intended, improving connection reliability.
  • Code Cleanliness: Removed unnecessary code, making the codebase slightly leaner and easier to maintain.
  • Improved Dependency Management: Ensures all direct dependencies are properly declared, facilitating easier setup and preventing
    build/runtime issues for new contributors or deployments.
  • Enhanced Maintainability: The Pydantic version comment provides valuable context for future development and dependency management.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 27, 2025

Deploy Preview for airi-docs ready!

Name Link
🔨 Latest commit d5158ef
🔍 Latest deploy log https://app.netlify.com/projects/airi-docs/deploys/685f6c0ea6a8ba0008352a4e
😎 Deploy Preview https://deploy-preview-233--airi-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 27, 2025

Deploy Preview for airi-vtuber ready!

Name Link
🔨 Latest commit d5158ef
🔍 Latest deploy log https://app.netlify.com/projects/airi-vtuber/deploys/685f6c0e02d41400082915d7
😎 Deploy Preview https://deploy-preview-233--airi-vtuber.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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 retryWithExponentialBackoff function within packages/server-sdk/src/client.ts. The attempts++ increment was changed to attempts + 1 in 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 the onEvent method in packages/server-sdk/src/client.ts. This change eliminates unnecessary code, making the event listener management slightly leaner and clearer.
  • Dependency Management: Explicitly added @moeru/std and crossws to the devDependencies section of the root package.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

  1. 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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread package.json Outdated
Comment on lines +69 to +71
"vitest": "^3.2.4",
"@moeru/std": "^0.0.1",
"crossws": "^0.0.1"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

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"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks.

Comment thread package.json Outdated
@nekomeowww nekomeowww changed the title Fix: Client retry logic, redundant listener set, and missing dependencies fix: Client retry logic, redundant listener set Jun 27, 2025
Copy link
Copy Markdown
Member

@nekomeowww nekomeowww left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

@nekomeowww nekomeowww merged commit 7f33a7a into moeru-ai:main Jun 28, 2025
6 of 8 checks passed
Disqort pushed a commit to Disqort/airi that referenced this pull request Aug 29, 2025
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.

2 participants