Skip to content

TypeError: _this.task is not a function #224

@wimdecorte

Description

@wimdecorte

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions