Fix deadlock in cache

This commit is contained in:
Szymon Nowakowski
2024-12-25 11:42:11 +01:00
parent 57fbe476cb
commit 8c15df8e06

View File

@@ -87,12 +87,13 @@ export const denormalizePiece = ({
Effect.flatMap(denormalizeSystemInformation), Effect.flatMap(denormalizeSystemInformation),
); );
const UserSemaphore = Effect.unsafeMakeSemaphore(1);
const CacheSemaphore = Effect.unsafeMakeSemaphore(4); const CacheSemaphore = Effect.unsafeMakeSemaphore(4);
export const userLookup = (userId: UserId) => pipe( export const userLookup = (userId: UserId) => pipe(
Effect.promise((signal) => client.user({ userId }).get({ fetch: { signal } })), Effect.promise((signal) => client.user({ userId }).get({ fetch: { signal } })),
Effect.flatMap(mapResponse), Effect.flatMap(mapResponse),
CacheSemaphore.withPermits(1), UserSemaphore.withPermits(1),
); );
export const pieceLookup = (pieceId: PieceId) => pipe( export const pieceLookup = (pieceId: PieceId) => pipe(