bottleneck on npm

2.17.1 (03 Mar 2019 23:03)

Distributed task scheduler and rate limiter


GitHub Releases

v2.17.0 25 Feb 2019 00:02
  • Bottleneck now ensures that jobs passed to schedule() and wrap() will return a promise, even if it failed with a synchronous exception. It is poor practice in JS to mix synchronous and asynchronous failures in the same flow. Few users will be affected by this change, and those who are affected will now benefit from more reliable code as a result.

Thank you @elliot-nelson for this feature https://github.com/SGrondin/bottleneck/pull/116

  • Bottleneck Clustering now cleans up Redis data from unresponsive clients. This change has no effect on functionality, directly or otherwise. Previously, Bottleneck left the data in Redis to avoid complex race conditions when unresponsive clients reconnect after a delay. As of v2.17.0, those race conditions are explicitly handled and Bottleneck cleans up data on the fly. These changes allowed for several efficiency optimizations. Large scale users should notice improved performance. More details in #115 and #112
v2.16.2 10 Feb 2019 23:02
  • Wrapped functions now inherit their this context. It allows for much nicer object-oriented code.

Thank you @elliot-nelson for this feature.

var object = {
    value: "Hello World",
    hello: limit.wrap(function () {
        return this.value;
    })
};

// When calling `object.hello()`, `this` = `object`
object.hello().then(console.log);
  • Clustering code now handles timeout events (Redis key TTL expiration) more efficiently.
v2.16.1 07 Feb 2019 15:02
  • Fix an edge case when using Clustering at high load and/or in a large Cluster. A race condition could occur that left the data in a corrupted state.
v2.16.0 03 Feb 2019 20:02
  • Added limiter.clusterQueued(). Returns the total weight of queued jobs in the Cluster.
  • Fixed an edge case when using Clustering and the BLOCK strategy, after the Cluster entered Blocked mode.
v2.15.3 15 Jan 2019 20:01
  • Fixed a memory leak that prevented limiters from being garbage collected until limiter.disconnect() was called.
  • Fixed a small memory leak in limiter instantiation (2kb / instantiation).
v2.15.2 13 Jan 2019 04:01
  • Fixed an issue with Clustering, introduced in 2.14.0 or 2.15.1 depending on whether replication is being used, where it would not register that a client has become unresponsive, and this would lead to the whole cluster getting "stuck" due to assigning priority to that client. It would then only launch new jobs every 4-5s. This has been fixed and a strong test added.
v2.15.1 12 Jan 2019 18:01
  • Fixed a script exception when using Redis Cluster. More information in this issue.
v2.15.0 31 Dec 2018 22:12
  • Added the 'failed' and 'retry' events. Bottleneck now support retries. See the Docs.
v2.14.1 23 Dec 2018 21:12
  • Adds a light bundle and exposes Bottleneck's internal Events library. See https://github.com/octokit/plugin-throttling.js/pull/1#issuecomment-449662827
v2.14.0 18 Dec 2018 20:12
  • Clustering now spreads load evenly across instances in the Cluster
  • When using Clustering, group.deleteKey(key) now deletes keys (across the Cluster) even if they are not present in the local Group instance
  • Added group.clusterKeys(). Unlike group.keys(), it returns all Group keys in the Cluster, not just those in the local Group instance.
v2.13.2 04 Dec 2018 05:12
  • Fixed an edge case where limiter.updateSettings() would fail when using Clustering and both maxConcurrent and reservoir are null after applying the new settings.
v2.13.1 01 Dec 2018 23:12
v2.13.0 03 Nov 2018 16:11
  • Added support for ES5 in Bottleneck v2. import Bottleneck from "bottleneck/es5";
v2.12.2 21 Oct 2018 20:10
  • Added Bottleneck.BottleneckError to the TypeScript typings file.
v2.12.1 13 Oct 2018 18:10
  • Optimized and improved accuracy of Batching
v2.12.0 09 Oct 2018 14:10
  • Added new standalone feature called Batching. new Bottleneck.Batcher({ maxTime: 1000, maxSize: 25 }); See Documentation for more information.
v2.11.2 02 Oct 2018 18:10
  • Fixed Node process exiting early due to the reservoir reaching 0 when there are still queued jobs. This has been the source of much confusion for new users.
  • Optimized entering Blocked Mode when using Clustering.
v2.11.1 27 Sep 2018 18:09
  • Fixed an issue with reservoir refresh where the very first refresh would happen too early.
  • Reduced the heartbeat for local datastores to 250ms. It is still 5000ms for redis/ioredis datastores. This allows local limiters to set a reservoirRefreshInterval value as low as 250ms.
v2.11.0 21 Sep 2018 00:09
  • Added the ability to manually control the creation and reuse of Redis connections via the connection option and the Bottleneck.RedisConnection and Bottleneck.IORedisConnection objects.
v2.10.0 13 Sep 2018 20:09
  • Added the done() method which returns the total weight of completed jobs across the Cluster.
  • Added a new "Reservoir Refresh" feature. Every reservoirRefreshInterval, the reservoir value is automatically reset to reservoirRefreshAmount.
  • Fixed a number of edge cases with Clustering and improved its performance.

It is strongly recommended to upgrade to this version if you are using Clustering.

v2.9.0 06 Sep 2018 18:09
  • Added support for pubsub across the Cluster. Use the publish() method and listen to the message event on a limiter.
  • Removed the need to wait for the ready() promise to complete before issuing commands. The commands will be queued until the limiter successfully connects. Make sure to listen to the error event to handle connection errors.
  • Added the jobs() method to return a list of job ids in a specific state.
  • Fixed an edge case with certain methods (like check()) when a Group key is recreated after timing out.
v2.8.0 20 Aug 2018 20:08
  • To use ioredis instead of Node Redis, pass the following option to Bottleneck: { datastore: "ioredis" }. ioredis supports Redis Cluster and Redis Sentinel
  • To use Redis Cluster, pass the following options to Bottleneck: { datastore: "redis", clusterNodes: [nodes] }. See the ioredis cluster docs and the Bottleneck docs for more information
v2.7.2 20 Aug 2018 13:08
  • Fixed an issue where some limiter options were not properly marked as nullable.
v2.7.1 20 Aug 2018 13:08
  • Fixed a Clustering issue where limiters would sometimes fail with a NOSCRIPT error.
v2.7.0 20 Aug 2018 13:08
  • All limiters within a Group now share the same Redis connection. Standalone limiters continue to have their own limiters.
  • Added the timeout option to limiters to allow freeing Redis state after a period of inactivity.
  • Fixed a bug when using Groups, Clustering, highWater and job expirations.
v2.6.0 20 Aug 2018 13:08
  • Added support for passing job options to a wrapped function.
const wrapped = limiter.wrap(fn);
wrapped.withOptions(options, arg1, arg2);
v2.5.1 03 Jul 2018 01:07
  • Fixed a memory leak where autogenerated job IDs would progressively get longer and take more memory. All users are advised to upgrade to this version. There are no breaking changes.
v2.5.0 03 Jul 2018 01:07
  • Added the stop() method, which allows safely stopping a limiter and executing work once completed. See Readme.
v2.4.0 09 Jun 2018 19:06
  • Jobs with duplicate IDs are now rejected instead of throwing an exception.
v2.3.1 19 May 2018 18:05
  • Fixed a warning when using Webpack v4
  • Relaxed the requirement to return a promise from .schedule().
v2.3.0 counts(), jobStatus() 09 Apr 2018 15:04

This release brings visibility into the status of limiters and jobs.

  • Added .counts() which returns an object with the number of jobs in every stage of their lifecycle.
  • Added .jobStatus(). It takes a jobId and returns the status of that job.
  • Added trackDoneStatus, a new limiter option, defaulted to false. Setting it to true will make your limiter keep track of Done jobs in .counts() and .jobStatus(). It is false by default, since it involves remembering every jobId that has ever reached the Done stage, which could lead to a memory leak if your application processes tens or hundreds of millions of jobs between restarts.
v2.2.2 Fix .on()/.once() fix, Fix Group Cluster GC 24 Mar 2018 18:03
  • Fixed .on() and .once() not returning the object itself, which broke "chaining" and compatibility with Node's own events. Fixes #59 , thanks @bkw for the bug report
  • Fixed key reuse for Groups when using Clustering. Fixes #57 , thanks @TheGame2500 for the bug report
v2.2.1 Fix when using Cluster+Group+Expiration 18 Mar 2018 18:03
  • Fixed an issue when using Clustering in a Group with maxConcurrent greater than 0 with jobs having an expiration time. A job timing out in a limiter in the group would lower the count of running jobs in all limiters in the group, which would result in going over the rate limit.
  • Improved the error message when returning a non-Promise value to schedule()
v2.2.0 Babel, Clustering for Groups 13 Mar 2018 01:03
  • Bottleneck v2 now ships code that is compatible with Node v6 instead of requiring Node v7.6. Thanks Babel.
  • Groups now support Clustering. Each limiter is automatically garbage collected, including its Redis data and even in the cases where Node loses connection to Redis.
  • Returning a promise to Bottleneck from within an event listener on a limiter now ensures your promise gets fully executed before exiting your program.
  • The depleted event now passes an empty argument.
v2.1.0 `depleted` event, better Redis error 22 Feb 2018 00:02
  • Added the depleted event. It is triggered when the reservoir reaches 0.
  • Return a friendly error message when a client tries to submit requests to a limiter which is still in the process of connecting to Redis and therefore cannot accept the request yet.
v2.0.1 Fixed TypeScript issue with noImplicitAny 16 Jan 2018 15:01
  • Fixed compilation when compiling using TypeScript and the --noImplicitAny compiler option
v2.0.0 Version 2 14 Jan 2018 19:01

Bottleneck Version 2

This new version is almost 100% compatible with Version 1 and it adds some powerful features such as:

  • True Clustering support. You can now rate limit and schedule jobs across multiple Node.js instances. It uses strictly atomic operations to stay reliable in the presence of unreliable clients. 100% of Bottleneck's features are supported.
  • Support for custom job weights. Not all jobs are equally resource intensive.
  • Support for job timeouts. Bottleneck can automatically cancel jobs if they exceed their execution time limit.
  • Many improvements to the interface, such as better method names and errors, improved debugging tools.

Upgrading to v2

The internal algorithms essentially haven't changed from v1, but many small changes to the interface were made to introduce new features.

All the breaking changes:

  • Bottleneck v2 uses ES6/ES2015. v1 will continue to use ES5 only.
  • The Bottleneck constructor now takes an options object.
  • Jobs take an optional options object.
  • Removed submitPriority(), use submit() with an options object instead.
  • Removed schedulePriority(), use schedule() with an options object instead.
  • The rejectOnDrop option is now true by default.
  • Use null instead of 0 to indicate an unlimited maxConcurrent value.
  • Use null instead of -1 to indicate an unlimited highWater value.
  • Renamed changeSettings() to updateSettings(), it now returns a promise to indicate completion. It takes the same options object as the constructor.
  • Renamed nbQueued() to queued().
  • Renamed nbRunning to running(), it now returns its result using a promise.
  • Removed isBlocked().
  • Changing the Promise library is now done through the options object like any other limiter setting.
  • Removed changePenalty(), it is now done through the options object like any other limiter setting.
  • Removed changeReservoir(), it is now done through the options object like any other limiter setting.
  • Removed stopAll(). Use the reservoir feature to disable execution instead.
  • check() now accepts an optional weight argument, and returns its result using a promise.
  • The Cluster feature is now called Group. This is to distinguish it from the new v2 Clustering feature.
  • The Group constructor takes an options object to match the limiter constructor.
  • Renamed the Group changeTimeout() method to updateSettings(), it now takes an options object.

Version 2 is more user-friendly, powerful and reliable.

v2.0.0-beta.4 Version 2: beta 4 29 Dec 2017 22:12
v2.0.0-beta.3 Version 2: beta 3 28 Dec 2017 18:12
v2.0.0-beta.2 Version 2: beta 2 27 Dec 2017 17:12
v2.0.0-beta.1 Version 2: beta 1 17 Dec 2017 04:12
v1.16.0 Type definitions and Cluster.changeTimeout() 19 Jun 2017 22:06
  • Added TypeScript type definitions thanks to @alexperovich
  • Added Cluster.changeTimeout()
v1.15.1 Fixed missing args in 'dropped' event from schedule() 19 Jan 2017 00:01
  • Propagate the arguments coming from promise()/promisePriority() into the task runner so that the dropped event shows the arguments that were given to Bottleneck.
v1.15.0 Safer stopAll() 30 Oct 2016 15:10
  • Changed internal representation of jobs tracking from a sparse array to an object. Fixes #25
  • Instead of disabling submit/submitPriority/schedule/schedulePriority, stopAll() now makes those functions automatically reject any new requests with a descriptive error. This should save a lot of frustration and help users debug their programs.
v1.14.0 'idle' event, removeAllListeners(), nbRunning() 05 Oct 2016 17:10
  • Added the idle event. It is emitted when both nbQueued() and nbRunning() drop to 0, which means there is nothing running and nothing queued up.
  • Added the removeAllListeners() method which follows the same pattern as the standard Node.js method of the same name. It supports an optional event name as first argument.
  • Added the nbRunning() method which returns the number of requests currently running in the limiter.
v1.13.1 Fixed issue with callbacks and rejectOnDrop 25 Sep 2016 15:09
  • Fixed an issue where the callback arguments when using rejectOnDrop with submit and submitPriority would be shifted when the job would be dropped.
v1.13.0 Added rejectOnDrop 25 Sep 2016 15:09
  • Added a new constructor parameter: rejectOnDrop. When set to true, dropped jobs will be failed/rejected with the Error This job has been dropped by Bottleneck.
v1.12.0 Changed high water default 07 May 2016 20:05
  • Default highWater value went from 0 (unlimited) to -1 (unlimited). This makes it possible to create limiters that drop anything that would have gone into the queue, in order words setting highWater to 0 will create a limiter that will only accept requests that will be executed immediately.
v1.11.0 Added support for events 23 Mar 2016 16:03
  • Added .on('empty', callback)
  • Added .on('dropped', callback)
v1.10.2 Fixed documentation 23 Mar 2016 16:03
  • Bottleneck.Promise = ... --> Bottleneck.prototype.Promise
v1.10.1 23 Jan 2016 02:01

Fixed bug #8 thanks to @albertreed

v1.10.0 23 Jan 2016 02:01
  • Added submitPriority()
  • Added schedulePriority()
  • Added nbQueued()
  • Added hasJobs()
  • Added strategy OVERFLOW_PRIORITY
  • Changed the underlying "engine" from Array to a custom very efficient data structure, see DDList.coffee, especially with over 1,000 jobs in a limiter.
v1.9.1 31 Aug 2015 16:08
  • Fixed Promise issue on Node 0.10 when bluebird isn't installed.
v1.9.0 22 Aug 2015 04:08
  • Added stopAutoCleanup()
  • Added startAutoCleanup()
  • Added deleteKey()
v1.8.1 14 Jul 2015 14:07
  • Bottleneck now uses Bluebird by default and falls back to the native Promise object if Bluebird is unavailable.
v1.8.0 14 Jul 2015 14:07
  • Added schedule(), fixed #4
v1.7.2 14 Jul 2015 14:07

Updated documentation, fixed #3

v1.7.1 11 May 2015 02:05
  • Added isBlocked()
v1.7.0 22 Mar 2015 00:03
  • Added chain()
v1.6.0 22 Mar 2015 00:03
  • Added the Cluster system
  • Updated to CoffeeScript 1.9
v1.5.3 22 Mar 2015 00:03
  • Updated to CoffeeScript 1.8
v1.5.2 22 Mar 2015 00:03
  • Fixed a bug in the BLOCK strategy
v1.5.1 22 Mar 2015 00:03
  • Fixed a bug in changeSettings()
v1.5.0 22 Mar 2015 00:03
  • Added the Reservoir system
v1.4.1 22 Mar 2015 00:03
  • Published to Bower
v1.4.0 22 Mar 2015 00:03
  • Added check()
  • Added the interrupt parameter for stopAll()
v1.3.1 21 Mar 2015 23:03
  • Updated the penalty value for the BLOCK strategy
v1.3.0 21 Mar 2015 23:03
  • Added the BLOCK strategy
v1.2.0 21 Mar 2015 23:03
  • added highWater
  • added strategies:
    • LEAK
    • OVERFLOW
v1.1.2 21 Mar 2015 23:03
  • Small performance improvements
v1.1.1 21 Mar 2015 23:03
  • Fixed a memory leak
v1.1.0 21 Mar 2015 23:03
  • Added changeSettings()
  • Allow null callbacks
  • Updated to CoffeeScript 1.7

Version History

Version Date
2.17.1 03 Mar 2019 23:03
2.17.0 25 Feb 2019 00:02
2.16.2 10 Feb 2019 22:02
2.16.1 05 Feb 2019 19:02
2.16.0 03 Feb 2019 20:02
2.15.3 15 Jan 2019 20:01
2.15.2 13 Jan 2019 04:01
2.15.1 12 Jan 2019 18:01
2.15.0 28 Dec 2018 20:12
2.14.1 23 Dec 2018 20:12
2.14.0 16 Dec 2018 05:12
2.13.2 04 Dec 2018 04:12
2.13.1 01 Dec 2018 23:12
2.13.0 03 Nov 2018 16:11
2.12.2 21 Oct 2018 20:10
2.12.1 13 Oct 2018 18:10
2.12.0 09 Oct 2018 14:10
2.11.2 02 Oct 2018 17:10
2.11.1 27 Sep 2018 17:09
2.11.0 20 Sep 2018 20:09
2.10.0 13 Sep 2018 20:09
2.9.0 06 Sep 2018 18:09
2.8.0 20 Aug 2018 20:08
2.7.2 17 Aug 2018 22:08
2.7.1 13 Aug 2018 14:08
2.7.0 12 Aug 2018 19:08
2.6.0 08 Jul 2018 16:07
2.5.1 03 Jul 2018 01:07
2.5.0 16 Jun 2018 19:06
2.4.0 09 Jun 2018 18:06
2.3.1 19 May 2018 18:05
2.3.0 08 Apr 2018 18:04
2.2.2 24 Mar 2018 17:03
2.2.1 18 Mar 2018 18:03
2.2.0 13 Mar 2018 01:03
2.1.0 22 Feb 2018 00:02
2.0.1 16 Jan 2018 15:01
2.0.0 14 Jan 2018 19:01
1.16.0 19 Jun 2017 22:06
1.15.1 19 Jan 2017 00:01
1.15.0 30 Oct 2016 15:10
1.14.0 05 Oct 2016 17:10
1.13.1 25 Sep 2016 15:09
1.13.0 25 Sep 2016 15:09
1.12.0 07 May 2016 20:05
1.11.0 22 Mar 2016 15:03
1.10.2 08 Feb 2016 19:02
1.10.1 23 Jan 2016 01:01
1.10.0 19 Jan 2016 20:01
1.9.1 31 Aug 2015 16:08
1.9.0 22 Aug 2015 04:08
1.8.1 14 Jul 2015 14:07
1.8.0 14 Jul 2015 03:07
1.7.2 12 Jul 2015 02:07
1.7.1 07 May 2015 18:05
1.7.0 16 Mar 2015 05:03
1.6.0 16 Mar 2015 01:03
1.5.3 02 Oct 2014 18:10
1.5.2 11 Aug 2014 17:08
1.5.1 26 Jul 2014 17:07
1.5.0 24 Jul 2014 00:07
1.4.1 24 Jul 2014 00:07
1.4.0 14 Jul 2014 16:07
1.3.1 05 Jul 2014 06:07
1.3.0 03 Jul 2014 00:07
1.2.0 07 Jun 2014 21:06
1.1.2 25 Apr 2014 16:04
1.1.1 23 Mar 2014 19:03
1.1.0 16 Mar 2014 22:03
1.0.0 20 Jan 2014 05:01
0.1.0 20 Jan 2014 03:01