refine
refine copied to clipboard
[BUG] `useImport` all batches are sent at once instead of one after the other
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
Hey @KrishnaPG , Thank you for contacting us! How about creating a PR?
Hey @KrishnaPG ,
We've released @pankod/[email protected]. Could you approve this fix?
Tested the @pankod/[email protected] for the batchSize and it is working as expected. Thank you for the fix