Skip to content

fix(use_timeout_fn): cancel pending timer on start()#307

Merged
maccesch merged 1 commit into
Synphonyte:mainfrom
EvanCarroll:main
May 18, 2026
Merged

fix(use_timeout_fn): cancel pending timer on start()#307
maccesch merged 1 commit into
Synphonyte:mainfrom
EvanCarroll:main

Conversation

@EvanCarroll

Copy link
Copy Markdown
Contributor

use_timeout_fn's start previously overwrote the stored TimeoutHandle without clearing it, leaving the prior browser setTimeout scheduled. Both the old and new callbacks would fire, silently breaking the "call start() again to reschedule" pattern.

This matches VueUse's useTimeoutFn.start, which explicitly clears before re-scheduling and is the behavior the leptos-use API surface advertises by being a VueUse port.

Closes #306

`use_timeout_fn`'s `start` previously overwrote the stored
`TimeoutHandle` without clearing it, leaving the prior browser
`setTimeout` scheduled. Both the old and new callbacks would fire,
silently breaking the "call start() again to reschedule" pattern.

This matches VueUse's `useTimeoutFn.start`, which explicitly clears
before re-scheduling and is the behavior the leptos-use API surface
advertises by being a VueUse port.

Closes Synphonyte#306
@EvanCarroll

Copy link
Copy Markdown
Contributor Author

this also adds a test which demonstrates the problem, and fails without the patch.

@maccesch

Copy link
Copy Markdown
Contributor

This is excellent work, thanks!

@maccesch maccesch merged commit d6fbf1d into Synphonyte:main May 18, 2026
4 checks passed
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.

use_timeout_fn: start() does not cancel pending timer (diverges from VueUse)

2 participants