linshenkx/prompt-optimizer · error · FavoriteStorageError

Failed to delete favorite prompt asset version: ${errorMessa

Error message

Failed to delete favorite prompt asset version: ${errorMessage}

What it means

Wrapped FavoriteStorageError thrown when an unexpected (non-FavoriteError) exception escapes deleteFavoritePromptAssetVersion — typically a storage failure in the underlying storageProvider (read/parse/write of favorites data). Known domain errors like FavoriteNotFoundError/FavoriteValidationError are rethrown untouched; everything else is wrapped with the original message for context.

Source

Thrown at packages/core/src/services/favorite/manager.ts:582

          },
        };
        assertFavoriteFitsItemBudget(nextFavorite);

        favoritesList[index] = nextFavorite;
        assertFavoritesPayloadWithinBudget(favoritesList, {
          warnOnSoftLimit: true,
        });

        return favoritesList;
      });

      await this.updateStats();
    } catch (error) {
      if (error instanceof FavoriteError) {
        throw error;
      }
      const errorMessage = error instanceof Error ? error.message : String(error);
      throw new FavoriteStorageError(`Failed to delete favorite prompt asset version: ${errorMessage}`);
    }
  }

  async deleteFavorite(id: string): Promise<void> {
    await this.ensureInitialized();

    try {
      await this.storageProvider.updateData(this.STORAGE_KEYS.FAVORITES, (favorites: FavoritePrompt[] | null) => {
        const favoritesList = favorites || [];
        const index = favoritesList.findIndex(f => f.id === id);
        if (index === -1) {
          throw new FavoriteNotFoundError(id);
        }

        return favoritesList.filter(f => f.id !== id);
      });

      await this.updateStats();

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Inspect error.message / inner cause to identify the underlying storage failure
  2. Clear or repair the corrupted favorites entry in storage (re-export/import a known-good copy)
  3. Reduce stored payload size (prune old versions/favorites) if quota is the issue
  4. If using a custom storageProvider, verify its updateData contract and error behavior
Defensive patterns

Strategy: try-catch

Type guard

const isFavoriteStorageError = (e: unknown): e is FavoriteStorageError => e instanceof FavoriteStorageError;

Try / catch

try { await manager.deleteFavoritePromptAssetVersion(id, vId); } catch (e) { if (e instanceof FavoriteStorageError) { /* inspect e.message for underlying storage cause; possibly retry */ } else throw e; }

Prevention

When it happens

Trigger: storageProvider.updateData or getFavorite throwing a low-level error during the delete flow: corrupted JSON in storage, quota exceeded, backend/network failure of a remote storage provider, or a serialization bug in the prompt asset metadata.

Common situations: localStorage quota exceeded in browsers with large prompt assets; remote sync storage offline; corrupted persisted JSON after a partial write or version migration; storage disabled in privacy modes.

Related errors


AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27). Data as JSON: /api/errors/d4d612c0a19990de. Report an issue: GitHub.