Skip to content

Commit f24b5b7

Browse files
committed
Protect against doWork getting called mulitple times per consumer
1 parent cb81d6c commit f24b5b7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

apps/webapp/app/v3/marqs/devQueueConsumer.server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ export class DevQueueConsumer {
9090
return;
9191
}
9292

93+
if (this._backgroundWorkers.has(backgroundWorker.id)) {
94+
return;
95+
}
96+
9397
this._backgroundWorkers.set(backgroundWorker.id, backgroundWorker);
9498

9599
logger.debug("Registered background worker", { backgroundWorker: backgroundWorker.id });
@@ -271,10 +275,10 @@ export class DevQueueConsumer {
271275
return;
272276
}
273277

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

277-
this._enabled = true;
278282
this._perTraceCountdown = this._options.maximumItemsPerTrace;
279283
this._lastNewTrace = new Date();
280284
this._taskFailures = 0;

0 commit comments

Comments
 (0)