refactor: resolve all no-floating-promises lint violations#13743
Merged
refactor: resolve all no-floating-promises lint violations#13743
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: icarus <[email protected]>
Add proper await for async operations that need completion guarantees: - ipc.ts: await setAppLaunchOnBoot, flushStore, closeAllConnections - SpanCacheService.ts: await cleanHistoryTrace, saveSpans, fs operations Add void for intentional fire-and-forget calls in sync contexts. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: icarus <[email protected]>
…ooks, and store Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: icarus <[email protected]>
…nents Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: icarus <[email protected]>
…d windows Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: icarus <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: icarus <[email protected]>
GeorgeDong32
approved these changes
Mar 23, 2026
Collaborator
There was a problem hiding this comment.
Note
This review was translated by Claude.
Code Review Summary
This PR high-quality resolved 608 no-floating-promises lint warnings.
Phase 1 (Behavior Changes) ✅
App_SetLaunchOnBoot: Correctly await async operationsApp_FlushAppData: Ensure data flush completes before returningSpanCacheService: Correctly await filesystem operations
Phase 2 (No Behavior Changes) ✅
- ~600
voidadditions are all correct fire-and-forget patterns
CI passed, recommended to merge.
Original Content
代码审查总结
该 PR 高质量地解决了 608 个 no-floating-promises lint 警告。
Phase 1(行为变更)✅
App_SetLaunchOnBoot: 正确 await async 操作App_FlushAppData: 确保数据刷新完成后再返回SpanCacheService: 正确 await 文件系统操作
Phase 2(无行为变更)✅
- ~600 处
void添加均为正确的 fire-and-forget 模式
CI 通过,推荐合并。
DeJeune
approved these changes
Mar 24, 2026
…floating-promises
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Before this PR:
The
typescript/no-floating-promiseslint rule was disabled ("off"), allowing 608 unhandled Promise expressions across 258 files.After this PR:
The rule is enabled (
"warn") and all 608 warnings are resolved. Async operations that genuinely neededawaitnow have it; intentional fire-and-forget calls are explicitly marked withvoid.Why we need it and why it was done in this way
Floating promises silently swallow errors and can cause hard-to-debug race conditions. Enabling this rule prevents future regressions.
A two-phase approach was used:
Phase 1 — Manual review (behavior change): Identified ~10 locations inside
asyncfunctions where missingawaitwas a potential bug, and added properawait:src/main/ipc.ts:App_SetLaunchOnBoothandler →setAppLaunchOnBoot()isasync(filesystem operations on Linux). Withoutawait, errors were silently lost.App_FlushAppDatahandler →cookies.flushStore()andcloseAllConnections()return Promises. Withoutawait, data flush was not guaranteed before the handler returned.src/main/services/SpanCacheService.ts:cleanTopic()→cleanHistoryTrace(),saveSpans(), andfs.rm()were not awaited, so cleanup could complete out of order or fail silently.cleanLocalData()→ Converted.then()chain toawaitfor proper error propagation.Phase 2 — Auto-fix (no behavior change): The remaining ~600 warnings were all in contexts where
voidis the correct and only fix:useEffect,useCallback) — cannotawaitwindow.api.*from renderer) — by designqueue.add()in Redux thunks) — queue manages execution internallynotificationService.send()) — non-criticalshell.openExternal(),loadURL(),loadFile()) — errors handled via Electron eventsThe following tradeoffs were made:
Using
voidfor fire-and-forget calls makes intent explicit but does not add error handling. This preserves existing behavior while making the code self-documenting.The following alternatives were considered:
.catch()to all 600+ call sites — rejected because it would require deciding error handling logic for each site, and none of these were handling errors before.Breaking changes
None. Phase 2 (
voidadditions) has zero runtime behavior change. Phase 1 (awaitadditions) fixes potential bugs but does not change the happy-path behavior.Special notes for your reviewer
Focus review on the
awaitadditions (Phase 1) as these are the only behavior changes:src/main/ipc.ts— 2 IPC handlers now properlyawaitasync operationssrc/main/services/SpanCacheService.ts—cleanTopic()andcleanLocalData()now properlyawaitfilesystem operationsThe remaining 256 files are mechanical
voidadditions fromoxlint --fix-suggestions— spot-check a few to confirm correctness, but exhaustive review is not needed.Checklist
/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note