- await this.db.context(async (dbCtx) => {
- if (wanted > 0) {
- // Update topics before anything else.
- const topicFetchIds = await this.db.topicFetchClaim(dbCtx, wanted, claimTimeoutSeconds, nodeId);
- // Each task gets a new context, as these map to connections in some dbs.
- // This dbCtx goes away after launching the processing functions, so would not be available to tasks.
- topicFetchPromises = topicFetchIds.map((id) => this.db.context((ctx) => this.topicFetchProcess(ctx, id, requestId)));
- inProgress.push(...topicFetchPromises);
- wanted -= topicFetchPromises.length;
- }
+ if (wanted > 0) {
+ // Update topics before anything else.
+ const topicFetchIds = await this.db.topicFetchClaim(dbCtx, wanted, claimTimeoutSeconds, nodeId);
+ topicFetchPromises = topicFetchIds.map((id) => this.db.context((ctx) => this.topicFetchProcess(ctx, id, requestId)));
+ inProgress.push(...topicFetchPromises);
+ wanted -= topicFetchPromises.length;
+ }