Просмотр исходного кода

fix: prevent shop details page from failing when Qdrant API calls fail

Changed Promise.all() to Promise.allSettled() for Qdrant data loading,
allowing the shop details page to load successfully even if embeddings
or errors endpoints fail. The shop details API call is now prioritized
and Qdrant data is loaded as optional supplementary information.

This fixes the "Failed to load shop details" error when Qdrant endpoints
experience issues or are unavailable.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fszontagh 8 месяцев назад
Родитель
Сommit
4e21981391
1 измененных файлов с 15 добавлено и 11 удалено
  1. 15 11
      web/src/components/pages/ShopDetailPage.ts

+ 15 - 11
web/src/components/pages/ShopDetailPage.ts

@@ -37,22 +37,26 @@ export class ShopDetailPage {
 
 
   private async loadShopDetail(): Promise<void> {
   private async loadShopDetail(): Promise<void> {
     try {
     try {
-      // Load shop details and Qdrant data in parallel
-      const [shopResponse, embeddingsResponse, errorsResponse] = await Promise.all([
-        this.apiService.getShop(this.shopId),
-        this.apiService.getShopQdrantEmbeddings(this.shopId),
-        this.apiService.getShopQdrantErrors(this.shopId)
-      ]);
+      // Load shop details first (critical)
+      const shopResponse = await this.apiService.getShop(this.shopId);
 
 
       if (shopResponse.success && shopResponse.data) {
       if (shopResponse.success && shopResponse.data) {
         this.shopDetail = shopResponse.data;
         this.shopDetail = shopResponse.data;
 
 
-        // Load Qdrant data (these can fail without breaking the page)
-        if (embeddingsResponse.success && embeddingsResponse.data) {
-          this.qdrantEmbeddings = embeddingsResponse.data.embeddings;
+        // Load Qdrant data in parallel (optional - these can fail without breaking the page)
+        const [embeddingsResponse, errorsResponse] = await Promise.allSettled([
+          this.apiService.getShopQdrantEmbeddings(this.shopId),
+          this.apiService.getShopQdrantErrors(this.shopId)
+        ]);
+
+        // Handle embeddings response (won't break if it fails)
+        if (embeddingsResponse.status === 'fulfilled' && embeddingsResponse.value.success && embeddingsResponse.value.data) {
+          this.qdrantEmbeddings = embeddingsResponse.value.data.embeddings;
         }
         }
-        if (errorsResponse.success && errorsResponse.data) {
-          this.qdrantErrors = errorsResponse.data.errors;
+
+        // Handle errors response (won't break if it fails)
+        if (errorsResponse.status === 'fulfilled' && errorsResponse.value.success && errorsResponse.value.data) {
+          this.qdrantErrors = errorsResponse.value.data.errors;
         }
         }
 
 
         this.renderShopDetail();
         this.renderShopDetail();