react-native-background-upload icon indicating copy to clipboard operation
react-native-background-upload copied to clipboard

Queuing of requests

Open dcurletti opened this issue 6 years ago • 5 comments

Hi there- curious if this library has a queuing system in place to limit the number of simultaneous api calls?

ie. If you invoke Upload.startUpload(options).then() X number of times, what would occur?

dcurletti avatar Aug 03 '19 02:08 dcurletti

I believe they will upload in parallel, but it's worth testing. A queueing system sounds like something people would like so I'll keep this open with help wanted

TSMMark avatar Aug 03 '19 03:08 TSMMark

@TSMMark ios and android only allow for a certain number of concurrent requests to be made, is that correct?

From this documentation, it seems to be implying 6 for ios: https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration/1407597-httpmaximumconnectionsperhost?language=objc

dcurletti avatar Aug 05 '19 22:08 dcurletti

i believe on android the requests are being queued by the package android-upload-service.

dcurletti avatar Aug 22 '19 22:08 dcurletti

i am using react-native-queue to control the flow of upload images.

andrejunqueira1 avatar Feb 18 '20 19:02 andrejunqueira1

This might seem like a naive approach, but maybe it will work.

Could you wrap the Upload functionality in a Promise so that the completed event resolves the promise?

Then use something like https://github.com/sindresorhus/p-map with concurrency: 1 to provide the concurrency limit?

I'm not sure how that would play with the background sessions.

deevus avatar Sep 16 '22 02:09 deevus