Continuing #2, I am concerned with the simple scenario where the rate at which executions are being made exceeds the rate at which they are resolved due to the throttling config. This time, the concern is not around memory exhaustion, but around the ever-growing delay in executing the next call being made.
Using the abort
function is a way to deal with this situation, with two drawbacks as I see them:
pThrottle.AbortError
. I'd love to have an option to have aborted executions resolve with a value that depends on the execution arguments.As a solution, I'm basically thinking of adding a way to peek into the throttledFn object, and extending the abort
function with the following options
argument:
throttledFn.countPending(): Number
throttledFn.abort({
count: Number, // default undefined, meaning to abort all pending executions
applyToLastInvocations: Boolean, // default false, applies to earliest invocations
resolveWithValue: Function, // a non-async function that takes the `Fn` arguments of each execution, and resolves the aborted execution with `resolveWithValue.apply(args)`. Default undefined, meaning to reject with `pThrottle.AbortError`
})
Would appreciate feedback on relevance, direction, and anything else.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too