From eec735471d1b2e6dfb98575bb539a6c10a3fef2a Mon Sep 17 00:00:00 2001
From: Travis Vachon <travis@storacha.network>
Date: Tue, 8 Oct 2024 06:23:37 +0200
Subject: [PATCH] feat: add debugging around production error (#427)

we're seeing this error a LOT in production but don't have much
information to debug from - add a bit of logging to try to figure out what's going on
---
 upload-api/stores/agent/stream.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/upload-api/stores/agent/stream.js b/upload-api/stores/agent/stream.js
index 58a991fd..75a6686c 100644
--- a/upload-api/stores/agent/stream.js
+++ b/upload-api/stores/agent/stream.js
@@ -115,9 +115,13 @@ export const assert = async (message, { stream, store }) => {
       // 🔬 Need to figure if there are consumers downstream that depend on
       // having invocation details in the stream record and whether we can
       // safely remove it because this additional IO which seems unnecessary.
-      const { ok: invocation } = await Store.getInvocation(store, task)
+      const result = await Store.getInvocation(store, task)
+      const { ok: invocation } = result
       if (!invocation) {
-        throw new NoInvocationFoundForGivenReceiptError()
+        console.error(result.error)
+        throw new NoInvocationFoundForGivenReceiptError(
+          `Could not find invocation with CID ${task.link().toString()} for receipt with CID: ${receipt.link().toString()}`
+        )
       }
 
       // log any likely JSON serialization errors in the receipt