Skip to content

Commit 55fb1f3

Browse files
committed
Handle division by 0 possibility in distributeQueues
1 parent 406c72d commit 55fb1f3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class SimpleWeightedChoiceStrategy implements MarQSQueuePriorityStrategy
6464
const totalQueueWeight = sortedQueues.reduce((sum, queue) => sum + queue.totalWeight, 0);
6565
const weightedQueues = sortedQueues.map(({ queue, totalWeight }) => ({
6666
queue,
67-
probability: totalWeight / totalQueueWeight,
67+
probability: totalQueueWeight > 0 ? totalWeight / totalQueueWeight : 1.0,
6868
}));
6969

7070
// Apply some randomization while maintaining general weight order

0 commit comments

Comments
 (0)