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

fix: useDebounce race condition (#139) #141

Closed
wants to merge 3 commits into from
Closed

Conversation

Coronon
Copy link
Contributor

@Coronon Coronon commented Nov 2, 2024

Superseded by #146

Rewrite useDebounce to gracefully handle new debounced calls while a previous call is running.
We isolate all actual callback invocations from each other by using a new set of timeout, promise, resolve and reject when their previously associated callback begins to run.

Fixes #139

Current broken reproduction:
https://stackblitz.com/edit/sveltejs-kit-template-default-bpdvwu?file=src%2Froutes%2F%2Bpage.svelte

New working reproduction:
https://stackblitz.com/edit/sveltejs-kit-template-default-uvrj4j?file=src%2Froutes%2F%2Bpage.svelte

This PR should also greatly improve DX for #134 which I would implement after this is merged :)

Copy link

changeset-bot bot commented Nov 2, 2024

🦋 Changeset detected

Latest commit: 6d15216

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
runed Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Coronon Coronon marked this pull request as draft November 2, 2024 01:51
@Coronon Coronon marked this pull request as ready for review November 2, 2024 01:56
@huntabyte
Copy link
Member

Hey @Coronon, thanks a ton for this!

Would you mind reopening this on a named branch that isn't main? It won't let allow me to make updates when it is your main branch.

@Coronon Coronon deleted the branch svecosystem:main November 25, 2024 07:19
@Coronon Coronon closed this Nov 25, 2024
@Coronon Coronon deleted the main branch November 25, 2024 07:19
@Coronon Coronon restored the main branch November 25, 2024 07:20
@Coronon
Copy link
Contributor Author

Coronon commented Nov 25, 2024

Superseded by #146

Hope this allows you to edit :)

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

Successfully merging this pull request may close these issues.

useDebounce race condition when already running -> can lose new call
2 participants