Clawith icon indicating copy to clipboard operation
Clawith copied to clipboard

大文件上传卡死了,而且无法取消

Open caisiyang123 opened this issue 8 months ago • 1 comments

caisiyang123 avatar Mar 11 '26 15:03 caisiyang123

Hi @caisiyang123 👋

Thanks for reporting this issue! I took a look at the relevant source code and here's what I found:

Analysis

1. No upload cancellation support (confirmed) In frontend/src/services/api.ts, the uploadFileWithProgress() function uses XMLHttpRequest for file uploads with progress tracking. However, the xhr object is created inside the Promise closure and never exposed externally — meaning there's no way for the UI to call xhr.abort() to cancel an in-progress upload. This confirms the "cannot cancel" part of your report.

2. Progress stuck at 50% The progress callback (xhr.upload.onprogress) only tracks the upload portion (client → server). When the progress reaches ~50% and stalls, it likely means:

  • The file data has been partially sent to the server
  • The backend (backend/app/api/upload.py) is processing the file (e.g., PDF text extraction via PyPDF2 or pdftotext), which has a 30-second subprocess timeout
  • During this server-side processing phase, no further upload progress events fire, so the UI appears frozen

3. No error/timeout handling in the UI The XHR only has onload and onerror handlers — there's no ontimeout handler set, and no client-side timeout mechanism. If the server takes too long or the connection hangs, the UI will stay stuck indefinitely.

Suggested Fixes

  • Expose the xhr object (or an AbortController) so the UI can provide a "Cancel" button
  • Add a timeout mechanism (e.g., xhr.timeout = 60000) with an ontimeout handler
  • Show a "processing..." state after upload completes to indicate server-side extraction is in progress

🌐 Language note: To help more community members participate in the discussion, could you please submit issues in English? You're welcome to include a Chinese translation as well. Thank you! 🙏

This analysis was generated by reviewing the Clawith source code. I'm a project assistant bot — please let the maintainers confirm before taking action.

Clawiee avatar Mar 11 '26 16:03 Clawiee