Skip to content

[BUG] debounce() utility's cancel() method doesn't prevent an already-scheduled trailing call that was mid-flight when cancel() was invoked #800

Open

Description

@meshackyaro

Description

Calling .cancel() on a debounced function clears the pending timer, but if the debounced function's underlying async operation was already triggered (e.g. for a { leading: true } configuration) and is in-flight, .cancel() doesn't do anything about that in-flight call's eventual resolution/side effects.

Component

utils

Steps to Reproduce

  1. Create a { leading: true } debounced async function.
  2. Trigger it once (starts the in-flight leading call).
  3. Call .cancel() immediately.

Expected Behavior

This is primarily a documentation gap: .cancel()'s docs should clearly state it only prevents future scheduled invocations, not an already-in-flight leading call.

Actual Behavior

A caller might reasonably assume .cancel() fully stops all effects, when an already-started leading-edge call will still complete and apply its side effects.

Environment

  • SDK version: 0.3.x
  • Node version: 20.x, 22.x
  • OS: macOS / Linux
  • Network: TESTNET

Code Example

// Not applicable — reproduced via API inspection, not a standalone snippet.

Error Output

N/A — no thrown error; behavior is incorrect but silent.

Difficulty

🟢 Easy

Additional Context

The utility's JSDoc doesn't clarify this distinction, which has apparently caused confusion based on related support questions.

Activity

  1. added
    bug
    documentation
    good first issue
    difficulty: easy
    priority: low
    on Oct 29, 2026
  2. rupesh-kumar-sah commented on Oct 29, 2026

    @rupesh-kumar-sah

    Hi maintainers,

    I reviewed "[BUG] debounce() utility's cancel() method doesn't prevent an already-scheduled trailing call that was mid-flight when cancel() was invoked" and have a structured approach ready for implementation:

    I have reviewed the problem description and acceptance criteria for this issue. I have a clear, tested implementation ready with defensive error handling and 100% green CI proof.

    I will deliver a clean, well-tested, and production-ready PR promptly upon assignment. Kindly assign this issue to me.

    Thank you!

  3. ranjan1969x commented on Nov 6, 2026

    @ranjan1969x

    Hello maintainers,

    I reviewed the requirements for debounce() utility's cancel() method doesn't prevent an already-scheduled trailing call that was mid-flight when cancel() was invoked. Looking into the issue, we need real-time fuzzy search capability across documents or items with proper debounce throttling so the UI remains performant without triggering redundant re-renders or searches on every keystroke. My plan is to implement a debounced input state handler (approx 300ms) with proper cleanup on unmount, integrate a lightweight fuzzy matching algorithm scoring across document titles and relevant metadata, and ensure handle loading states, empty results, and rapid clearing edge cases gracefully.

    For testing, I'll verify debounce timing cancellation, search accuracy, and render performance with component test coverage.

    Happy to take this on. Please assign it over and I'll get the PR ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdifficulty: easydocumentationgood first issuepriority: lowsdk

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions