fix(worker): avoid workers getting blocked

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-09-13 17:50:13 +02:00
parent efd24ca67a
commit 447f303aa4

View File

@@ -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;
};
}