From e89d3c334edae15a9274056ff6e0379bc1479eb6 Mon Sep 17 00:00:00 2001 From: Michal Kalita Date: Tue, 2 Sep 2025 11:14:50 +0200 Subject: [PATCH] fix: prevent server crash when cost is missing in response --- src/main.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index d81d5b0..8b8a3cf 100644 --- a/src/main.ts +++ b/src/main.ts @@ -105,9 +105,8 @@ server.register(FastifyProxy, { return; } - // eslint-disable-next-line prefer-destructuring - const cost = data.usage.cost; - if (!cost) { + const cost = data?.usage?.cost; + if (!cost || typeof cost !== 'number') { request.log.error({ data }, 'Cannot read cost from response'); return; }