Description
When using WebFlux to upload large files, the upload process sometimes hangs before reaching the route's business logic. Specifically, the issue occurs during the client’s file upload to the org.springframework.http.codec.multipart.MultipartParser
when writing to a temporary file, causing the upload to become stuck. This problem is intermittent but has a certain probability of occurring when uploading files of 200MB, between 2-3GB, and between 4-5GB.
Steps to Reproduce
- Set up a Spring Boot application using WebFlux to handle file upload requests.
- Upload a large file (e.g., 200MB, 2-3GB, or 4-5GB).
- Observe the upload process. Occasionally, the upload hangs before the file is fully transmitted to the server. At this point, the generated temporary file
xxx.multipart
is incomplete, and the request remains in a pending state without completing the upload.
Additional Resources
- A minimal reproduction project has been provided that can replicate the aforementioned issue, However, it’s not guaranteed to happen every time; I tried a few times: large-file-upload.zip
- Screen Recording Demonstration:
https://github.com/user-attachments/assets/4d92b3e3-df14-4217-9081-52a321516900
- Relevant logs: upload-file.log
In the screen recording, I used an ISO file that I downloaded from the Manjaro official website: https://download.manjaro.org/gnome/24.2.1/manjaro-gnome-24.2.1-241216-linux612.iso
The file upload progress in the video is stuck at 68% and does not complete, regardless of how long you wait, with no error messages displayed
Expected Behavior
Large files should upload and be processed smoothly without hanging or blocking at any stage.
Actual Behavior
When uploading large files, the upload process sometimes hangs during the MultipartParser
phase of writing to the temporary file, preventing the upload from completing.
Environment Information
- Spring Boot Version: 3.4.1
- Java Versions:
- OpenJDK 17
- Eclipse Temurin JDK 21.0.5
- Operating Systems:
- macOS
- Linux
- Other Relevant Dependencies:
spring-boot-starter-webflux
Note: The issue has been tested and reproduced across all the above-mentioned systems and JDK versions.
Additional Information
This issue is not caused by business logic but by the framework’s handling of large file uploads and writing to temporary files, which leads to blocking. We hope the development team can investigate and resolve this issue to enhance the stability and reliability of large file uploads.
Comment From: guqing
Perhaps it would be more appropriate to raise this issue in the spring-framework project. I apologize for overlooking this. Could the developers please transfer this issue to the spring-framework repository?🤪