chore(lint): mark intentional fire-and-forget promises with void in a2a-server#27686
chore(lint): mark intentional fire-and-forget promises with void in a2a-server#27686Eswar809 wants to merge 1 commit into
Conversation
…2a-server Eliminates the two `@typescript-eslint/no-floating-promises` suppressions in a2a-server by using the `void` operator, the idiomatic way to mark an intentionally un-awaited promise. Both call sites are deliberately fire-and-forget and cannot/should not be awaited: - agent/executor.ts: `pushTaskStateFailed` is async but its body only performs a synchronous `eventBus.publish`, so the returned promise is already settled; not awaiting it is harmless. - agent/task.ts: the enclosing `addToolResponsesToHistory` method is synchronous (returns `void`), so `addHistory` cannot be awaited without changing the method's public signature. Behavior is unchanged; `void` only documents the existing intent. Part of google-gemini#19440
Summary of ChangesHello, 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 addresses linter warnings regarding floating promises within the a2a-server package. By utilizing the void operator, the changes explicitly document the intentional fire-and-forget nature of specific asynchronous calls, maintaining existing behavior while adhering to project-wide linter hygiene standards. Highlights
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 the 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 counterproductive. 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. Footnotes
|
|
📊 PR Size: size/XS
|
There was a problem hiding this comment.
Code Review
This pull request replaces ESLint disable comments with the void operator to handle floating promises in executor.ts and task.ts. Feedback on both changes suggests appending a .catch() block to safely handle and log potential promise rejections, preventing potential Node.js process crashes from unhandled rejections.
| ); | ||
| // eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
| pushTaskStateFailed(error, eventBus, taskId, contextId); | ||
| void pushTaskStateFailed(error, eventBus, taskId, contextId); |
There was a problem hiding this comment.
Using void to discard a floating promise suppresses the linter warning, but it does not handle potential promise rejections. If pushTaskStateFailed rejects (for example, if eventBus.publish throws an error), it will result in an unhandled promise rejection, which can crash the Node.js process.
To prevent this, attach a .catch() handler to log or handle the error.
void pushTaskStateFailed(error, eventBus, taskId, contextId).catch((err) => {
logger.error('[CoderAgentExecutor] Failed to push task state failed:', err);
});| } | ||
| // eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
| this.geminiClient.addHistory({ | ||
| void this.geminiClient.addHistory({ |
There was a problem hiding this comment.
Using void to discard the promise returned by this.geminiClient.addHistory suppresses the linter warning, but it leaves potential promise rejections unhandled. If the history update fails, it will trigger an unhandled promise rejection, which can crash the Node.js process.
Consider appending a .catch() block to safely handle and log any failures.
void this.geminiClient.addHistory({
role: 'user',
parts,
}).catch((error) => {
logger.error('[Task] Failed to add history to Gemini client:', error);
});
Summary
Part of the linter hygiene epic (#19440), which calls out misuse of promises as a target. This eliminates the two
@typescript-eslint/no-floating-promisessuppressions in a2a-server using thevoidoperator — the idiomatic way to mark an intentionally un-awaited promise.Both call sites are deliberately fire-and-forget and cannot/should not be awaited:
agent/executor.ts—pushTaskStateFailedisasync, but its body only performs a synchronouseventBus.publish, so the returned promise is already settled by the time it is created; not awaiting it is harmless.agent/task.ts— the enclosingaddToolResponsesToHistorymethod is synchronous (returnsvoid), soaddHistorycannot be awaited without changing the method's public signature.Behavior
Unchanged —
voidonly documents the already-existing fire-and-forget intent; noawaitis introduced, so timing and control flow are identical.Testing
eslintclean on both filestsc --noEmitpasses for@google/gemini-cli-a2a-serverexecutor.test.ts(2) andtask.test.ts(16)