Submit listener exceptions leave isSubmitting stuck true
維護者通常 1 天內回覆
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 72/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- typescript
- 領域
- backend
研究方向
先閱讀 form-core 中 FormApi.handleSubmit() 的實作及其提交錯誤處理區塊;issue 指出,表單和欄位對 listeners.onSubmit 的同步呼叫就在該區塊之前執行。為這兩種 listener 情況新增迴歸測試,檢查錯誤仍會被拒絕、提交回呼會被略過,且 isSubmitting 會重設為 false,而 isSubmitSuccessful 維持 false。確認之後的成功提交可以正常運作,並執行 form-core 測試套件。
由索引模型根據 Issue 內容生成。
描述
Describe the bug
A synchronous exception in a form-level or field-level listeners.onSubmit rejects form.handleSubmit() but leaves form.state.isSubmitting set to true. The submit callback itself is correctly skipped, but a UI that disables its submit button while submitting stays disabled after the rejected listener.
The form already resets this lifecycle state when the main onSubmit callback throws. The listener calls currently run just before that error-handling block.
Minimal reproduction
import { FormApi } from '@tanstack/form-core'
const form = new FormApi({
defaultValues: { name: 'Ada' },
listeners: {
onSubmit: () => { throw new Error('Submit listener failed') },
},
})
form.mount()
try {
await form.handleSubmit()
} catch (error) {
console.log((error as Error).message) // Submit listener failed
}
console.log(form.state.isSubmitting) // true; expected false
The same result occurs when the throwing listener is attached to a mounted FieldApi instead of the form.
Expected behavior
The original exception should still reject handleSubmit() and prevent the submission callback from running, while isSubmitting returns to false and isSubmitSuccessful stays false. A later successful submission should work normally.
Verification
Reproduced on current main (eba4084, form-core 1.33.5), Node 24.19.0. Two regression tests (form listener and field listener) fail on main because isSubmitting remains true. Moving those synchronous listener calls into the existing submission error-handling block makes both pass; the form-core suite passes 507 tests with 3 existing todo tests and no type errors.
This report and the proposed repair were prepared with Codex assistance and checked locally. The scope is synchronous submit listener exceptions; it does not promise handling of detached asynchronous work started by a listener.
- 主要語言
- TypeScript
- 星號
- 6.8k
- 分支
- 717
- 平均合併
- 5 天 22 小時
- 30 天內合併 PR
- 14
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
TanStack/form 的其他 Issue
-
難度 1/5 1 小時以內 新手友好度 88/100
維護者通常 1 天內回覆
-
handleSubmit calls onSubmit again while a submit is still pending (since 1.33.1)可能已有人在做 @twotnguyen 於 14 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
`isDefaultValue` is wrong when a field-level `defaultValue` is `null`可能已有人在做 @fenet-as 於 40 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
Async validator doesn't re-trigger `isValidating` after first failed validation可能已有人在做 @drewsephski 於 44 天前認領。 未關閉
難度 2/5 1-2 天 新手友好度 72/100
維護者通常 1 天內回覆
-
[v2 alpha] devtools are always light mode可能已有人在做 @dikshit-n 於 78 天前認領。 未關閉area: runtime scope: devtools type: bug v2
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
相似的 Issue
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難度 1/5 1 小時以內 新手友好度 92/100
lingdojo/kana-dojo#34449 · 1 則留言 · 5 個 reaction ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100
drizzle-team/drizzle-orm#6726 ·
維護者通常 2 天內回覆
-
bug platform-desktop platform-windows
難度 2/5 1-3 小時 新手友好度 74/100
Termix-SSH/Termix#1951 · 2 則留言 ·
維護者通常 1 天內回覆
-
Grok provider voice list shows 5 of xAI's 28 built-in voices可能已有人在做 @hkjarral 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 80/100
hkjarral/AVA-AI-Voice-Agent-for-Asterisk#883 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100