bottleneck icon indicating copy to clipboard operation
bottleneck copied to clipboard

TypeError: _this.task is not a function

Open wimdecorte opened this issue 8 months ago • 0 comments

Using a scheduler inside a loop:

image

The thing that I'm scheduling is definitely a function, returns a promise. Adding Promise.resolve() doesn't help. Reading the gotchas, if I put the loop inside the scheduler then the nothing gets throttled and the remote API is overwhelmed and throws errors.

Error on the code shown:

/Users/wdecorte/GitHub/twentyonezero-embeddings/node_modules/bottleneck/lib/Job.js:141 passed = yield chained != null ? chained.schedule(_this.options, _this.task, ..._this.args) : _this.task(..._this.args); ^

TypeError: _this.task is not a function at /Users/wdecorte/GitHub/twentyonezero-embeddings/node_modules/bottleneck/lib/Job.js:141:109 at Generator.next () at asyncGeneratorStep (/Users/wdecorte/GitHub/twentyonezero-embeddings/node_modules/bottleneck/lib/Job.js:3:103) at _next (/Users/wdecorte/GitHub/twentyonezero-embeddings/node_modules/bottleneck/lib/Job.js:5:194) at /Users/wdecorte/GitHub/twentyonezero-embeddings/node_modules/bottleneck/lib/Job.js:5:364 at new Promise () at /Users/wdecorte/GitHub/twentyonezero-embeddings/node_modules/bottleneck/lib/Job.js:5:97 at Job.doExecute (/Users/wdecorte/GitHub/twentyonezero-embeddings/node_modules/bottleneck/lib/Job.js:156:7) at Timeout._onTimeout (/Users/wdecorte/GitHub/twentyonezero-embeddings/node_modules/bottleneck/lib/Bottleneck.js:199:22) at listOnTimeout (node:internal/timers:573:17)

wimdecorte avatar Jun 05 '24 19:06 wimdecorte