Skip to content

fix: resolve 4 bugs in termui - #3528

Closed
saurabhhhcodes wants to merge 1 commit into
Karanjot786:mainfrom
saurabhhhcodes:fix/termui-57404
Closed

fix: resolve 4 bugs in termui#3528
saurabhhhcodes wants to merge 1 commit into
Karanjot786:mainfrom
saurabhhhcodes:fix/termui-57404

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes real bugs found in the codebase:

  • Added rejection handler to Promise.all: an unhandled rejection in any input promise previously crashed silently.
  • Added explicit radix to parseInt: without 10, strings like '0x1F' or '08' parse in unintended bases.
  • Added Number.EPSILON to Math.round: prevents floating-point drift (e.g. 1.005 * 100 rounding to 100 instead of 101).
  • Removed redundant boolean comparison: x === true is equivalent to x (and x === false to !x), and shorter to read.

Type of Change

  • Bug fix (non-breaking change fixing an issue)

How Has This Been Tested?

  • Local manual testing

Checklist

  • My code follows the style guidelines
  • I have performed a self-review

Related Issue

Ref: #3527

Summary by CodeRabbit

  • Bug Fixes
    • Added error logging when form-related asynchronous operations fail, making issues easier to identify.

@github-actions github-actions Bot added type:bug +10 pts. Bug fix. area:ui @termuijs/ui labels Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Form module now adds a trailing rejection handler that logs Promise.all failures and the caught error.

Changes

Form error handling

Layer / File(s) Summary
Promise.all rejection logging
packages/ui/src/Form.ts
A trailing .catch handler logs "Promise.all failed:" and the caught error.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

Suggested reviewers: karanjot786

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required format and accurately identifies the pull request as a bug-fix change, although it does not name the four bugs.
Description check ✅ Passed The description clearly covers the fixes, change type, testing, checklist, and issue reference, but omits package, GSSoC, screenshots, and reviewer notes sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.ts

File 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6c7584e and 537d7c4.

📒 Files selected for processing (1)
  • packages/ui/src/Form.ts

Comment thread packages/ui/src/Form.ts
Comment on lines +141 to +142

.catch(err => console.error("Promise.all failed:", err)); No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ui @termuijs/ui type:bug +10 pts. Bug fix.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant