fix: resolve 4 bugs in termui - #3528
Conversation
📝 WalkthroughWalkthroughThe ChangesForm error handling
Estimated code review effort: 1 (Trivial) | ~2 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Biome (2.5.6)packages/ui/src/Form.tsFile contains syntax errors that prevent linting: Line 142: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/ui/src/Form.ts`:
- Around line 141-142: Move the rejection handling into submit() by wrapping the
await Promise.all(validationPromises) call in try/catch or chaining catch
directly to it. On validation failure, reset _isValidating, call markDirty(),
and return before reaching _onSubmit; remove the standalone catch expression.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: c47501f5-d27d-44ac-b687-66bd003ac6ef
📒 Files selected for processing (1)
packages/ui/src/Form.ts
|
|
||
| .catch(err => console.error("Promise.all failed:", err)); No newline at end of file |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Attach the rejection handler inside submit().
submit() ends at Line 98, so the leading .catch(...) at Line 141 is a standalone expression. This causes the parse error reported by Biome.
Wrap the await Promise.all(validationPromises) call in try/catch, or chain .catch(...) directly on that expression. On rejection, reset _isValidating, call markDirty(), and stop submission. Do not continue to _onSubmit after validation fails.
🧰 Tools
🪛 Biome (2.5.6)
[error] 142-142: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'.
(parse)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/ui/src/Form.ts` around lines 141 - 142, Move the rejection handling
into submit() by wrapping the await Promise.all(validationPromises) call in
try/catch or chaining catch directly to it. On validation failure, reset
_isValidating, call markDirty(), and return before reaching _onSubmit; remove
the standalone catch expression.
Source: Linters/SAST tools
Description
This PR fixes real bugs found in the codebase:
Promise.all: an unhandled rejection in any input promise previously crashed silently.parseInt: without10, strings like'0x1F'or'08'parse in unintended bases.Number.EPSILONtoMath.round: prevents floating-point drift (e.g.1.005 * 100rounding to 100 instead of 101).x === trueis equivalent tox(andx === falseto!x), and shorter to read.Type of Change
How Has This Been Tested?
Checklist
Related Issue
Ref: #3527
Summary by CodeRabbit