-
-
Notifications
You must be signed in to change notification settings - Fork 40
Description
Describe the bug
The useBatchAddListener
hook occasionally delays the execution of its callback for more than 2 seconds. This randomness causes problems in our workflow, especially when the remote upload directory changes between the time files are selected and when the callback is finally executed.
Scenario
Our application allows users to select a remote directory for uploads. Due to the unpredictable delay in the useBatchAddListener
callback, the remote directory may be changed by the user before the hook executes. As a result, files can end up uploading to a directory different from the one intended at selection time.
To Reproduce
Steps to reproduce the behavior:
- Use the
useBatchAddListener
hook in a React component within a typical upload scenario. - Allow users to change the remote upload directory after selecting files.
- Observe that sometimes the callback is executed with a delay exceeding 2 seconds, and the files are uploaded to a directory different from the one selected during file selection.
Expected behavior
The callback registered by useBatchAddListener
should be executed immediately when the batch add event occurs, so the remote directory matches the user's intention at the time of selection.
Versions
- @rpldy/uploader: [please fill in]
- @rpldy/react-uploady: [please fill in]
- Browser: [please fill in]
Code
useBatchAddListener((batch) => {
// Uses current remote directory from state to determine upload target
console.log("batch add", batch, remoteDirectory);
});
// Sometimes this log appears with a delay of more than 2 seconds,
// and remoteDirectory has changed.
Any insight into what might be causing this delay, or if it is a bug in the hook implementation, would be appreciated.