diff --git a/servers/themes/src/counter/kv.ts b/servers/themes/src/counter/kv.ts index 378ecf37e..d8e09d524 100644 --- a/servers/themes/src/counter/kv.ts +++ b/servers/themes/src/counter/kv.ts @@ -28,7 +28,7 @@ type WorkersKVRESTConfig = { export class KVCounter { private readonly client: Cloudflare; private readonly mutex: Mutex; - private installs: Record = {}; + private installs: Record = {}; constructor(private readonly config: WorkersKVRESTConfig) { this.mutex = new Mutex(); this.client = new Cloudflare({ @@ -50,7 +50,7 @@ export class KVCounter { const result: Record = {}; const installs = await readMulti(this.client, this.config, keys); for (const [key, value] of Object.entries(installs)) { - result[key] = value.length; + result[key] = value?.length ?? 0; } this.installs = installs; return result; @@ -61,7 +61,7 @@ async function readMulti( client: Cloudflare, config: WorkersKVRESTConfig, keys: string[] -): Promise> { +): Promise> { try { const response = await client.kv.namespaces.bulkGet(config.namespaceId, { account_id: config.cfAccountId,