Skip to content

Commit

Permalink
Protect against doWork getting called mulitple times per consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
ericallam committed May 15, 2024
1 parent cb81d6c commit f24b5b7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/webapp/app/v3/marqs/devQueueConsumer.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export class DevQueueConsumer {
return;
}

if (this._backgroundWorkers.has(backgroundWorker.id)) {
return;
}

this._backgroundWorkers.set(backgroundWorker.id, backgroundWorker);

logger.debug("Registered background worker", { backgroundWorker: backgroundWorker.id });
Expand Down Expand Up @@ -271,10 +275,10 @@ export class DevQueueConsumer {
return;
}

this._enabled = true;
// Create the session
await createNewSession(this.env, this._options.ipAddress ?? "unknown");

this._enabled = true;
this._perTraceCountdown = this._options.maximumItemsPerTrace;
this._lastNewTrace = new Date();
this._taskFailures = 0;
Expand Down

0 comments on commit f24b5b7

Please sign in to comment.