-
-
Notifications
You must be signed in to change notification settings - Fork 5
Handle floating promises #3492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Handle floating promises #3492
Conversation
Thanks for tackling this @siltomato. One major concern I have is that it's going to create a slew of merge conflicts with #3199, which is already big, difficult, and affects async/await in a lot of places. Maybe we should merge the two instances you found that you think should be awaited, and then have the rest of them updated after #3199 to reduce conflicts (or at least to simplify the conflicts, since adding void is a lot simpler than the other PR's changes)? |
c001568
to
45423d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested merging this branch with #3199, and there were merge conflicts in just 5 files that were pretty straightforward to fix. But just for peace of mind, there's no harm in just waiting to merge this until that branch is merged.
Reviewable status: 0 of 70 files reviewed, all discussions resolved
@siltomato 5 straightforward fixes is very manageable. Let's proceed. |
There was a problem hiding this 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 addresses lint no-floating-promises
warnings throughout the codebase by adding void
to promises that are intentionally fire-and-forget. Two instances in the editor components use async/await for improved readability, and one instance in realtime-doc.ts
uses await
to maintain data consistency during deletion operations.
Key Changes
- Added
void
prefix to floating promises to maintain existing fire-and-forget behavior while satisfying linting requirements - Converted
onLeafNodeClick()
in lynx insights panel to async/await pattern for better readability - Changed
delete()
method in realtime-doc.ts to await adapter deletion for data consistency
Reviewed Changes
Copilot reviewed 69 out of 69 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/xforge-common/models/realtime-doc.ts |
Changed delete() method to await adapter deletion for consistency |
src/app/translate/editor/lynx/insights/lynx-insights-panel/lynx-insights-panel.component.ts |
Converted onLeafNodeClick() to async/await pattern |
Multiple service and component files | Added void prefix to floating promises across the application |
async delete(): Promise<void> { | ||
this.adapter.delete(); | ||
await this.adapter.delete(); | ||
await this.updateOfflineData(); | ||
await this.realtimeService.onLocalDocUpdate(this); | ||
} |
Copilot
AI
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change to await this.adapter.delete()
is correct for maintaining data consistency. However, consider adding error handling to ensure the subsequent operations don't execute if the adapter deletion fails, which could leave the document in an inconsistent state.
Copilot generated this review using guidance from repository custom instructions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the other pull request which deals with realtime doc cleanup, the order in which the disposal methods are called turns out to be very complicated and very important. I would suggest that we leave this line unchanged and fix it in the other pull request in the interest of simplicity. Basically, the situation is just too complicated for me to mentally untangle and be certain that this change is going to work with the changes in the other PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, changed await
to void
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we leave this line unchanged. The change might be correct, and the existing behavior could even be wrong. I'd rather have a lint warning reminding us to deal with it. Marking it void
is essentially saying "a developer looked at this and conclusively determined that we don't want to await this", which is definitely not correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Changed.
.../src/app/translate/editor/lynx/insights/lynx-insights-panel/lynx-insights-panel.component.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 70 files reviewed, all discussions resolved (waiting on @Nateowami)
.../src/app/translate/editor/lynx/insights/lynx-insights-panel/lynx-insights-panel.component.ts
Show resolved
Hide resolved
async delete(): Promise<void> { | ||
this.adapter.delete(); | ||
await this.adapter.delete(); | ||
await this.updateOfflineData(); | ||
await this.realtimeService.onLocalDocUpdate(this); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, changed await
to void
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nateowami dismissed @copilot from a discussion.
Reviewable status: 0 of 70 files reviewed, all discussions resolved
async delete(): Promise<void> { | ||
this.adapter.delete(); | ||
await this.adapter.delete(); | ||
await this.updateOfflineData(); | ||
await this.realtimeService.onLocalDocUpdate(this); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we leave this line unchanged. The change might be correct, and the existing behavior could even be wrong. I'd rather have a lint warning reminding us to deal with it. Marking it void
is essentially saying "a developer looked at this and conclusively determined that we don't want to await this", which is definitely not correct.
0bb903a
to
ef08444
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 70 files reviewed, all discussions resolved (waiting on @Nateowami)
async delete(): Promise<void> { | ||
this.adapter.delete(); | ||
await this.adapter.delete(); | ||
await this.updateOfflineData(); | ||
await this.realtimeService.onLocalDocUpdate(this); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Changed.
This PR fixes all lint
no-floating-promises
warnings. All files used thevoid
methodology to handle the floating promises (maintaining existing fire-and-forget behavior) except for the two instances described below.In the
lynx-insight-panel.component.ts
onLeafNodeClick()
function, the promise chain is changed to async/await. This is more of a readability change than functional, as, in both cases, the nav completes before the call to update display state.In the
realtime-doc.ts
delete()
function:await this.adapter.delete()
was chosen instead ofvoid this.adapter.delete()
with the idea to maintain data consistency in the case that theadapter.delete()
call fails. Please review if this is the correct approach.This change is