Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors in debounce fn are not propagated #130

Closed
yarinsa opened this issue Mar 29, 2022 · 1 comment
Closed

errors in debounce fn are not propagated #130

yarinsa opened this issue Mar 29, 2022 · 1 comment

Comments

@yarinsa
Copy link

yarinsa commented Mar 29, 2022

Describe the bug
The error inside the debounced function is swallowed

To Reproduce

  1. Make a-simple async function and throw error inside.
  2. Make a debounced instance of this function
  3. In other function use the debouncedFn and wrap it with try & catch block

Expected behavior
The error will be caught in the other function.

Actual behavior
The error is thrown outside and uncaught

use-debounce version: 7.0.1

@yarinsa
Copy link
Author

yarinsa commented Mar 29, 2022

Solved this way:

What I had:

const debouncedSave = useDebouncedCallback(
saveFunction,
1000,
{ maxWait: 3000 },
);

The solution:

const debouncedSave = useDebouncedCallback(
() => saveFunction(),
1000,
{ maxWait: 3000 },
);

@yarinsa yarinsa closed this as completed Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant