Network failures result in different `err` param passed to `onError`
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
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, react
- Lĩnh vực
- frontend
Hướng nghiên cứu
Bắt đầu trong request.js, so sánh handler xhr.onerror với đường dẫn lỗi của xhr.onload và lệnh gọi getError được hiển thị trong issue. Tái hiện lần upload bị chặn trong ví dụ đơn giản, sau đó xác minh rằng các lỗi mạng truyền một lỗi cho onError với thông báo hiển thị cho người dùng nhất quán với các lỗi máy chủ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Steps to reproduce
- Go to https://react-component.github.io/upload/examples/simple.html
- Upload a file
- Notice that as outlined in the example code
onError(err) {
console.log('onError', err);
},
a error message is printed. This error message could be used to show some diagnostics to the user. The error message is assembled via this function in request.js
xhr.onload = function onload() {
// allow success when 2xx status
// see https://github.com/react-component/upload/issues/34
if (xhr.status < 200 || xhr.status >= 300) {
return option.onError(getError(option, xhr), getBody(xhr));
}
return option.onSuccess(getBody(xhr), xhr);
};
This is all well and correct.
- Now in the Network tab of DevTools right click on the previous
upload.dorequest andBlockit from the menu (to simulate a network failure). - Upload a file - will be marked as
Blockedin the Network tab. - console.log(err) in onError now outputs a different error object without a message. This is totally different from the previous
errparameter and not usable for printing to the user anymore
Looking at the stacktrace this code now comes from
xhr.onerror = function error(e) {
option.onError(e);
};
also in request.js just above xhr.onload
Expected results
Network failures should also pass the same err object to the onError prop as there would be a server message failure, so that it is easier to show such errors to the user.
- Ngôn ngữ chính
- TypeScript
- Star
- 804
- Fork
- 323
- Merge trung bình
- 12 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 react-component/upload
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
react-component/upload#170 ·
-
HVAC websiteĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
react-component/upload#697 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 15/100
react-component/upload#615 ·
-
开启文件夹上传时就不能多选文件上传,可以解决吗?Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
react-component/upload#522 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
react-component/upload#515 ·
Tất cả issue của react-component/upload
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
aiko-chan-ai/DiscordBotClient#380 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
vercel/ai-elements#507 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 84/100
anaclumos/qa-interns#148 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày