refine icon indicating copy to clipboard operation
refine copied to clipboard

[BUG] `useImport` all batches are sent at once instead of one after the other

Open KrishnaPG opened this issue 3 years ago • 1 comments

Describe the bug When useImport is used with batchSize option, it is expected that the batches are sent one after another (i.e. next batch is sent to the server after the first batch processing completes). However, currently all batches are being sent at once (which is not correct), since it overloads the server with too many requests at the same times, and makes the batching pointless.

To Reproduce Use useImport with batchSize as below:

  const { uploadProps, buttonProps, mutationResult, isLoading } = useImport({
    batchSize: 10,
  });

and select a large file as upload input. You will seen all the batches being set at once to the server.

Expected behavior Batches should be sent one after another (i.e. after the first one returns, send the next one)

Additional context The code is sending the requests in a map, instead of in a forEach await-loop https://github.com/pankod/refine/blob/c1908141d25e38bbd67aa3e9eb755bf538369aba/packages/core/src/hooks/import/index.tsx#L222-L235

KrishnaPG avatar Sep 15 '22 08:09 KrishnaPG

Hey @KrishnaPG , Thank you for contacting us! How about creating a PR?

omeraplak avatar Sep 16 '22 07:09 omeraplak

Hey @KrishnaPG , We've released @pankod/[email protected]. Could you approve this fix?

omeraplak avatar Sep 22 '22 11:09 omeraplak

Tested the @pankod/[email protected] for the batchSize and it is working as expected. Thank you for the fix

KrishnaPG avatar Sep 22 '22 13:09 KrishnaPG