Skip to content

Discrepancy between lodash and compat throttle with both trailing and leading disabled #1494

Description

@DominikSerafin

While I was sanity-checking the reproduction on this issue, I've found that there's a discrepancy between lodash and compat throttle:

import lodashThrottle from 'lodash-es/throttle';
import compatThrottle from 'es-toolkit/compat/throttle';

const WAIT = 100;
const OPTIONS = {leading: false, trailing: false};

const lodashThrottled = lodashThrottle(() => console.log('lodashThrottled'), WAIT, OPTIONS);
const compatThrottled = compatThrottle(() => console.log('compatThrottled'), WAIT, OPTIONS);

// These seem to be mostly consistent on my machine
setInterval(lodashThrottled, 1);
setInterval(compatThrottled, 1);

// Things start to get inconsistent
setInterval(lodashThrottled, 100);
setInterval(compatThrottled, 100);

// Lodash now executes far more rarely, while compat seems to execute according to delay
// The lodash timing appears to grow exponentially compared to compat
setInterval(lodashThrottled, 115);
setInterval(compatThrottled, 115);

// Note: system/browser workload seems to increase the timing inconsistencies as well

This is a bit extreme edge case considering this seems to happen only with both trailing and leading edges disabled, but configuration like this is still implicitly allowed (even though the effects of doing so are not generally established), so I thought it deserved mention.

Activity

  1. self-assigned this
    on Nov 7, 2025
  2. constantly-dev commented on Dec 18, 2025

    @constantly-dev
    Contributor

    I'd like to work on this. Could you assign it to me?

  3. raon0211 commented on Jan 23, 2026

    @raon0211
    Collaborator

    This actually seems to be a bug

  4. constantly-dev commented on Jan 23, 2026

    @constantly-dev
    Contributor

    @raon0211 Thank you!
    I've left a comment on PR #1560 regarding the potential fix for the root cause. Could you please take a look?

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions