From 1eb5bac10bca9d2b901091565cbd8c14e0ef9e4e Mon Sep 17 00:00:00 2001 From: Vibhu Tomer Date: Mon, 11 May 2026 14:28:17 +0000 Subject: [PATCH] fix(firestore): add exists check to prevent crash on undefined document download --- Govt-Billing-React/src/firebase/firestore.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Govt-Billing-React/src/firebase/firestore.ts b/Govt-Billing-React/src/firebase/firestore.ts index bf8cd1b..e6f2c96 100644 --- a/Govt-Billing-React/src/firebase/firestore.ts +++ b/Govt-Billing-React/src/firebase/firestore.ts @@ -79,6 +79,9 @@ const downloadFileFromFirebase = async (userId, key, onSuccess) => { const local = new Local(); const getFile = async () => { const docSnapshot = await getDoc(doc(db, "invoices", `${userId}-${key}`)); + if (!docSnapshot.exists()) { + throw new Error("File not found on the server. It may have been deleted."); + } const data = docSnapshot.data(); delete data["owner"]; return data;