handleSubmit calls onSubmit again while a submit is still pending (since 1.33.1)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Báo cáo chỉ ra _handleSubmit và this.baseStore.state.isSubmitting trong @tanstack/form-core; hãy bắt đầu bằng cách lần theo lệnh trả về sớm và bước kiểm tra lần thử gửi được mô tả trong issue. Tái hiện lỗi bằng script Node được cung cấp trên mã hiện tại, sau đó thêm hoặc cập nhật kiểm thử hồi quy cho lần gửi thứ hai khi onSubmit vẫn đang chờ xử lý; công việc được xem là hoàn tất khi onSubmit chỉ được gọi một lần và hành vi gửi lại từ #2120 được giữ nguyên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
Since #2120 ("clear stale onBlur errors on re-submission", released in 1.33.1), handleSubmit skips its !canSubmit early return on every attempt after the first. canSubmit is also false while a submit is in flight, so a second handleSubmit during a pending onSubmit now runs validation and calls onSubmit again. Up to 1.33.0 that second call returned early.
In practice: a double tap on a submit button, or Enter / the keyboard's "go" pressed twice, sends the request twice. We hit it on a sign-in form and a comment composer in React Native, where the keyboard submit bypasses a disabled button.
Your minimal, reproducible example
No sandbox, it needs only @tanstack/form-core in Node:
// npm i @tanstack/[email protected], then: node repro.mjs
import { FormApi } from '@tanstack/form-core';
const pending = [];
const form = new FormApi({
defaultValues: { name: 'Ada' },
onSubmit: () => new Promise((resolve) => pending.push(resolve)),
});
form.mount();
const first = form.handleSubmit();
await new Promise((resolve) => setTimeout(resolve, 0));
console.log('isSubmitting:', form.state.isSubmitting, 'canSubmit:', form.state.canSubmit);
const second = form.handleSubmit();
await new Promise((resolve) => setTimeout(resolve, 0));
console.log('onSubmit calls:', pending.length, '(expected 1)');
pending.forEach((resolve) => resolve());
await Promise.all([first, second]);
Steps to reproduce
- Run the script with
@tanstack/[email protected]:isSubmitting: true canSubmit: false,onSubmit calls: 1. - Run it with
@tanstack/[email protected]: same state,onSubmit calls: 2.
Expected behavior
A handleSubmit that arrives while isSubmitting is true does not call onSubmit again, as before #2120. Keeping the re-submission behaviour #2120 added and also returning early when this.baseStore.state.isSubmitting is true would cover both.
How often does this bug happen?
Every time
Platform
@tanstack/form-core1.33.5 (via@tanstack/react-form1.33.5)- Node 26, and React Native 0.88 / Hermes in the app
TanStack Form adapter
react-form
TanStack Form version
1.33.5
TypeScript version
5.9
Additional context
The change is in _handleSubmit: if (!this.state.canSubmit && ...) { if (this.baseStore.state.submissionAttempts <= 1) { ...; return; } }. We now wrap onSubmit in a single-flight guard on our side.
- Ngôn ngữ chính
- TypeScript
- Star
- 6.8k
- Fork
- 705
- Merge trung bình
- 1 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/form
-
[v2] FieldWithValue<T> erases field.name to any instead of stringCó thể đã có người làm @Priyeshshrivastav đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
TanStack/form#2465 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`isDefaultValue` is wrong when a field-level `defaultValue` is `null`Có thể đã có người làm @fenet-as đã nhận 25 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
TanStack/form#2427 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Async validator doesn't re-trigger `isValidating` after first failed validationCó thể đã có người làm @drewsephski đã nhận 29 ngày trước. Đang mở
Độ khó 2/5 1-2 ngày Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[v2 alpha] devtools are always light modeCó thể đã có người làm @dikshit-n đã nhận 63 ngày trước. Đang mởarea: runtime scope: devtools type: bug v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
FormGroupApi.getRelatedFields and FieldApi.validate() use unguarded startsWith for group membership, matching unrelated fields with a shared name prefixCó thể đã có người làm @HDPark95 đã nhận 82 ngày trước. Đang mởarea: runtime scope: core type: bug v1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
TanStack/form#2337 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của TanStack/form
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
transitmatters/shutdown-tracker#155 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Popping out a single panel leaves its always render overlay in the main window, blocking clicksĐang mởbug triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
"Claude Code request is missing its initial user message" when the prompt starts with an image pathĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
earendil-works/pi-claude-code#31 ·
Maintainer thường phản hồi trong vòng 8 ngày
-
bug pending triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
privatenumber/cleye#48 ·