I'm building a React javascript application with a Nodejs and Express backend.
Versions: React: ^16.0.0 Node: v8.0.0 Express: ^4.14.0 Chrome: Version 63.0.3239.84 (Official Build) (64-bit)
The POST
request is a file upload, with the file attached to a FormData()
object. The server doesn't respond until the images are uploaded successfully to AWS S3. For large images, which take longer than approximately 10000ms to upload, Chrome re-initiates the POST
request. This causes the images to upload twice.
I've tested by setting a setTimeout
of 10000ms before sending the response back, and tested with a very small image. The image uploads just fine without the timeout. But with the timeout it will upload twice.
This behaviour doesn't happen in Firefox.
This thread seems to report the same issue I'm having: link .
Supposedly the server is sending back a 408 request, but I can't confirm that. How can I prevent Chrome from re-initiating the POST
request on large uploads?
Found the answer here :
app.post('/long_processing_thing', function(req, res){
req.setTimeout(0) // no timeout
do_something_long(req, res)
})
You can easily change the timeout of a request in express using req.setTimeout
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.