Skip to content

debounced function not working after Bun sleepSync #6003

@lawrenceching

Description

@lawrenceching

I found that debounced function was called at the first time and never be called again
If I use sleepSync, a sync version of sleep provided by Bun runtime.

import { sleepSync } from "bun";
import _ from 'lodash'

let count = 0

const debouncedFn = _.debounce(() => {
    count++
    console.log('>>> debouncedFn invoked, count:', count)
}, 1000, {
    leading: true,
})

for(let i = 0; i < 10; i++) {
    console.log('#', i)
    debouncedFn()
    sleepSync(2000)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions