This is only happening sometimes and noticed during investigating an error thrown by API during upload
The request fails the first time, it is then retried and returns a 200 OK. A 3rd request comes in which fails because the function was already updated. All 3 requests are milliseconds apart. Deploy finishes correctly.
Same behavior here.
All deploys are CLI deploys. There are probably more examples to be found going through this list.
Expected behavior: request is not retried if it is successful
Thanks @ingride, we would need to dive into the code here:
https://github.com/netlify/js-client/blob/4cb1f240bac527305ff98032a801accf22dea5bf/src/deploy/upload-files.js#L97
to make sure the retry mechanism is working as expected.
Note that all api.* methods (including the ones used during files upload) also have some generic retry logic here.
We are currently using node-fetch under the hood. I am wondering if switching to got would make sense from that angle, since they have some pretty advanced retry logic out-of-the-box.
I'll try to get a consistent reproduction. Was planning to do some stress testing on the CLI deploy as a part of https://github.com/netlify/cli/issues/745 and https://github.com/netlify/cli/issues/484 so it might be useful here too.
FYI, wrote a utility to seed a site with files and functions:
https://github.com/erezrokah/netlify-build-reproductions/blob/03310ae888957df6e6c971d1852c7b3c02be6991/seed.js#L93
Usage (all arguments are optional except --siteDir):
node seed.js --siteDir=public --fileCount=1000 --minSize=10 --maxSize=20 --depth=5 --functionsDir=functions --functionCount=10 --functionSize=1