Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: expiration

Nevo Davide0fe7d0381b3
diff --git a/libraries/helpers/src/utils/concurrency.service.ts b/libraries/helpers/src/utils/concurrency.service.ts
index 906e5f526..ce2065aee 100644
--- a/libraries/helpers/src/utils/concurrency.service.ts
+++ b/libraries/helpers/src/utils/concurrency.service.ts
@@ -1,6 +1,7 @@
import { ioRedis } from '@gitroom/nestjs-libraries/redis/redis.service';
import Bottleneck from 'bottleneck';
import { timer } from '@gitroom/helpers/utils/timer';
+import { BadBody } from '@gitroom/nestjs-libraries/integrations/social.abstract';
const connection = new Bottleneck.IORedisConnection({
client: ioRedis,
@@ -23,19 +24,28 @@ export const concurrency = async <T>(
minTime: 1000,
});
let load: T;
+
+ if (ignoreConcurrency) {
+ return await func();
+ }
+
try {
- if (ignoreConcurrency) {
- return await func();
- }
load = await mapper[strippedIdentifier].schedule<T>(
- { expiration: 600000 },
+ { expiration: 10000 },
async () => {
try {
return await func();
} catch (err) {}
}
);
- } catch (err) {}
+ } catch (err) {
+ throw new BadBody(
+ identifier,
+ JSON.stringify({}),
+ {} as any,
+ `Something is wrong with ${identifier}`
+ );
+ }
return load;
};