Skip to content

Conversation

@lionel-rowe
Copy link
Contributor

Closes #6796.

If fn returns a promise, lastExecution is now based on the asynchronous end time of the previous call. For example with this function:

async function fn() {
    const start = performance.now()
    while (performance.now() - start < 50) { /* idle  loop */ }
    await new Promise((res) => setTimeout(res, 100))
}

If the throttled function is called once at time 0 and we observe lastExecution at time 999, the current implementation would have it set to ~50, whereas the new implementation has it set to ~150. This will also affect how throttling works with asynchronous functions — the current implementation basically doesn't throttle at all for typical async functions, whereas the new one does.

@lionel-rowe lionel-rowe requested a review from kt3k as a code owner February 13, 2026 01:05
@github-actions github-actions bot added the async label Feb 13, 2026
@lionel-rowe lionel-rowe changed the title feat(async/unstable): allow setting dynamic timeframe for throttle feat(async/unstable): allow setting dynamic timeframe for throttle Feb 13, 2026
@lionel-rowe lionel-rowe marked this pull request as draft February 13, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@std/async throttle dynamically adjusted timeframe

1 participant