You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-29Lines changed: 21 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,7 @@ More importantly, this library has been rewritten with modern-day JS (courtesy o
18
18
19
19
### Breaking changes in v4
20
20
21
+
- The callback-style `submit()` method has been removed — Bottleneck is now Promise-only. Use `schedule()`, wrapping callback-style functions with [`util.promisify`](https://nodejs.org/api/util.html#utilpromisifyoriginal). The `Bottleneck.Callback` type is gone from the typings.
21
22
- The ES5 build has been removed (`require("bottleneck/es5")` no longer exists). If you need broad-browser support, use the UMD `@sderrow/bottleneck/light` build instead.
22
23
- Cluster mode now requires `redis` v4+ (drops v2/v3) or `ioredis` v5+. The unsupported `redis` v2/v3 client API has been removed.
23
24
-`ioredis` and `redis` are now optional **peer dependencies**. Your application must install whichever client it uses.
@@ -35,7 +36,6 @@ See [Upgrading to v4](#upgrading-to-v4) for migration steps.
35
36
-[Gotchas & Common Mistakes](#gotchas--common-mistakes)
36
37
-[Constructor](#constructor)
37
38
-[Reservoir Intervals](#reservoir-intervals)
38
-
-[`submit()`](#submit)
39
39
-[`schedule()`](#schedule)
40
40
-[`wrap()`](#wrap)
41
41
-[Job Options](#job-options)
@@ -153,16 +153,11 @@ const result = await wrapped(arg1, arg2);
153
153
154
154
#### ➤ Using callbacks?
155
155
156
-
Instead of this:
156
+
Bottleneck is Promise-only. Wrap callback-style functions with [`util.promisify`](https://nodejs.org/api/util.html#utilpromisifyoriginal) and `schedule()` them:
- If you plan on using `priorities`, make sure to set a `maxConcurrent` value.
221
216
222
-
-**When using `submit()`**, if a callback isn't necessary, you must pass `null` or an empty function instead. It will not work otherwise.
223
-
224
-
-**When using `submit()`**, make sure all the jobs will eventually complete by calling their callback, or set an [`expiration`](#job-options). Even if you submitted your job with a `null` callback , it still needs to call its callback. This is particularly important if you are using a `maxConcurrent` value that isn't `null` (unlimited), otherwise those not completed jobs will be clogging up the limiter and no new jobs will be allowed to run. It's safe to call the callback more than once, subsequent calls are ignored.
217
+
-**Make sure your jobs eventually settle** (resolve or reject), or set an [`expiration`](#job-options). With a `maxConcurrent` value that isn't `null` (unlimited), jobs whose promises never settle clog the limiter and no new jobs will be allowed to run.
225
218
226
219
- Using tools like `mockdate` in your tests to change time in JavaScript will likely result in undefined behavior from Bottleneck.
227
220
@@ -301,21 +294,9 @@ Reservoir Intervals are an advanced feature, please take the time to read and un
301
294
302
295
-**Reservoir Intervals prevent a limiter from being garbage collected.** Call `limiter.disconnect()` to clear the interval and allow the memory to be freed. However, it's not necessary to call `.disconnect()` to allow the Node.js process to exit.
303
296
304
-
### submit()
305
-
306
-
Adds a job to the queue. This is the callback version of `schedule()`.
You can pass `null` instead of an empty function if there is no callback, but `someAsyncCall` still needs to call **its** callback to let the limiter know it has completed its work.
313
-
314
-
`submit()` can also accept [advanced options](#job-options).
315
-
316
297
### schedule()
317
298
318
-
Adds a job to the queue. This is the Promise and async/await version of `submit()`.
299
+
Adds a job to the queue.
319
300
320
301
```js
321
302
constfn=function (arg1, arg2) {
@@ -360,12 +341,9 @@ wrapped()
360
341
361
342
### Job Options
362
343
363
-
`submit()`, `schedule()`, and `wrap()` all accept advanced options.
344
+
`schedule()` and `wrap()` accept advanced options.
@@ -1123,6 +1101,20 @@ The same applies to `Bottleneck.Group` and to the standalone `Bottleneck.RedisCo
1123
1101
1124
1102
If you previously hit "Bottleneck failed to require ioredis at runtime", that workaround paragraph is no longer needed. The implicit-require hack has been removed entirely.
1125
1103
1104
+
### `submit()` users
1105
+
1106
+
The callback API is gone. The one-line translation:
The minimum supported `redis` package version is now v4. The v2/v3 callback-style client API is no longer supported. Follow node-redis's own [v3-to-v4 migration guide](https://github.com/redis/node-redis/blob/master/docs/v3-to-v4.md) to upgrade your client. v5 is also fully supported.
0 commit comments