From 805230341e21fd5ea6e2747857ae3402a9a82eeb Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Fri, 1 Sep 2023 19:19:42 -0700 Subject: [PATCH] fix: :bug: unlock undefined --- .../src/services/fetch-instance-metadata.ts | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/backend/src/services/fetch-instance-metadata.ts b/packages/backend/src/services/fetch-instance-metadata.ts index 79354448f..4db1338e0 100644 --- a/packages/backend/src/services/fetch-instance-metadata.ts +++ b/packages/backend/src/services/fetch-instance-metadata.ts @@ -15,8 +15,6 @@ export async function fetchInstanceMetadata( instance: Instance, force = false, ): Promise { - const unlock = await getFetchInstanceMetadataLock(instance.host); - if (!force) { const _instance = await Instances.findOneBy({ host: instance.host }); const now = Date.now(); @@ -24,7 +22,7 @@ export async function fetchInstanceMetadata( _instance?.infoUpdatedAt && now - _instance.infoUpdatedAt.getTime() < 1000 * 60 * 60 * 24 ) { - unlock(); + await getFetchInstanceMetadataLock(instance.host); return; } } @@ -53,7 +51,7 @@ export async function fetchInstanceMetadata( } as Record; if (info) { - updates.softwareName = info.software?.name.toLowerCase(); + updates.softwareName = info.software?.name?.toLowerCase() || null; updates.softwareVersion = info.software?.version; updates.openRegistrations = info.openRegistrations; updates.maintainerName = info.metadata @@ -80,24 +78,24 @@ export async function fetchInstanceMetadata( } catch (e) { logger.error(`Failed to update metadata of ${instance.host}: ${e}`); } finally { - unlock(); + await getFetchInstanceMetadataLock(instance.host) } } type NodeInfo = { - openRegistrations?: any; + openRegistrations?: boolean; software?: { - name?: any; - version?: any; + name?: string; + version?: string; }; metadata?: { - name?: any; - nodeName?: any; - nodeDescription?: any; - description?: any; + name?: string; + nodeName?: string; + nodeDescription?: string; + description?: string; maintainer?: { - name?: any; - email?: any; + name?: string; + email?: string; }; }; };