fix: handle errors occurred in non-blocking sendMessage#187
fix: handle errors occurred in non-blocking sendMessage#187guglielmo-san merged 43 commits intoa2aproject:mainfrom
Conversation
feat: Implement linter and prettier
Summary of ChangesHello @guglielmo-san, 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 significantly improves the stability and maintainability of the A2A SDK. It addresses a critical issue where server processes could crash due to unhandled errors in non-blocking event loops, ensuring that such failures are now gracefully managed and reported. Additionally, the integration of Prettier and an updated ESLint configuration enforces a consistent code style, making the codebase easier to read and contribute to. Highlights
Ignored Files
Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces Prettier for code formatting and applies it across the entire codebase, which is a great step for consistency. It also seems to address a bug related to hanging promises. I've found a minor issue with an unused import in a new test mock file. Please see my comment for details.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses a critical issue where an error in the event loop for a non-blocking call could crash the server. The approach of catching the error and, if a response has already been sent, updating the task to a 'failed' state is correct.
However, the implementation of this fix introduces a new potential crash. If an error occurs after a message event (instead of a task event) has been sent, the code will attempt to access properties on an undefined object, leading to a TypeError. I've provided a critical review comment with a suggested fix to make the error handling more robust.
The other changes in this PR, including the addition of a new test case and stylistic updates to the types.ts file, are good.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively addresses a critical bug where the server could crash due to an unhandled promise rejection in non-blocking calls. The core change is in _processEvents, where the error handling logic is enhanced to catch errors that occur after an initial response has been sent. Instead of re-throwing the error, which caused the crash, the new logic updates the task's state to 'failed'. This is a robust solution that improves server stability. The addition of a targeted test case in default_request_handler.spec.ts is excellent, as it precisely simulates the failure scenario and verifies the fix. The overall changes are well-implemented and crucial for the reliability of non-blocking operations.
🤖 I have created a release *beep* *boop* --- ## [0.3.6](v0.3.5...v0.3.6) (2025-12-10) ### Features * add support for extendedAgentCard on client side ([#234](#234)) ([3073376](3073376)) * Add support for extension headers on client side ([#227](#227)) ([8c57002](8c57002)) * implement client interceptors ([#223](#223)) ([5694c22](5694c22)) * Implement extended card support on server side ([#197](#197)) ([45014ac](45014ac)) * implement server http+json ([#142](#142)) ([f20e662](f20e662)) * introduce AgentCardResolver ([#225](#225)) ([ddaf7de](ddaf7de)) * introduce transport agnostic client ([#198](#198)) ([94a9848](94a9848)) * server side support for extensions ([5ef7396](5ef7396)) * support authentication on server side ([#195](#195)) ([9872d93](9872d93)) ### Bug Fixes * handle errors occurred in non-blocking sendMessage ([#187](#187)) ([e55c0f4](e55c0f4)) ### Miscellaneous Chores * set version to 0.3.6 ([#191](#191)) ([3f8cea0](3f8cea0)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: Ivan Shymko <ishymko@google.com>
Description
This PR fixes the error of server crash in case of error in the event loop for non blocking event, if the first reply to the client has been already sent.
Two different error handling strategies are implemented based on the origin of the error:
In the catch clause a TaskStatusUpdateEvent is generated, with taskStatus equal to "failed", if an already existing Task has been processed by the ResultManager. The new TaskStatusUpdateEvent is saved in the taskStore. If a new error occurs within this operation, it is simply printed on the console error output.
Fixes #186 🦕