From 447f303aa48ad81852ed2779028a24761aa6d82b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Gerhard=20Lindesva=CC=88rd?= Date: Fri, 13 Sep 2024 17:50:13 +0200 Subject: [PATCH] fix(worker): avoid workers getting blocked --- apps/worker/src/jobs/events.incoming-event.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/worker/src/jobs/events.incoming-event.ts b/apps/worker/src/jobs/events.incoming-event.ts index 87bc2418..b5f7d314 100644 --- a/apps/worker/src/jobs/events.incoming-event.ts +++ b/apps/worker/src/jobs/events.incoming-event.ts @@ -183,6 +183,10 @@ function getSessionEndWithPriority( return async (args) => { const res = await getSessionEnd(args); + if (count > 10) { + throw new Error('Failed to get session end'); + } + // if we get simultaneous requests we want to avoid race conditions with getting the session end // one of the events will get priority and the other will wait for the first to finish if (res === null && priority === false) { @@ -190,10 +194,6 @@ function getSessionEndWithPriority( return getSessionEndWithPriority(priority, count + 1)(args); } - if (count > 10) { - throw new Error('Failed to get session end'); - } - return res; }; }