Skip to content

Commit c3af061

Browse files
committed
Update index.ts
1 parent ba3cf1c commit c3af061

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

workers/grouper/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ const DB_DUPLICATE_KEY_ERROR = '11000';
5353
*/
5454
const MAX_CODE_LINE_LENGTH = 140;
5555

56+
/**
57+
* Delay in milliseconds to wait for duplicate key event to be persisted to database
58+
*/
59+
const DUPLICATE_KEY_RETRY_DELAY_MS = 10;
60+
5661
/**
5762
* Worker for handling Javascript events
5863
*/
@@ -239,7 +244,7 @@ export default class GrouperWorker extends Worker {
239244
* Fetch the event that was just inserted by the competing worker
240245
* Add small delay to ensure the event is persisted
241246
*/
242-
await new Promise(resolve => setTimeout(resolve, 10));
247+
await new Promise(resolve => setTimeout(resolve, DUPLICATE_KEY_RETRY_DELAY_MS));
243248

244249
existedEvent = await this.getEvent(task.projectId, uniqueEventHash);
245250

0 commit comments

Comments
 (0)