Skip to content

Bug: PackageCard has no error handler; failed metadata loads become unhandled rejections #84

@mmcdermott

Description

@mmcdermott

Summary

`PackageCard` fires off `loadPackageMetadata(pkg).then(setData)` with no `.catch`. If the network call rejects (the underlying `readOrFetchToCache` throws when a fetch fails and there is no cached fallback), it surfaces as an unhandled promise rejection and the card stays in its initial `null` render forever.

Code pointers

  • `src/components/ecosystem/PackageCard.tsx` line 10:
    ```tsx
    useEffect(() => {
    loadPackageMetadata(pkg).then(setData);
    }, [pkg]);
    if (!data) return null;
    ```
  • `src/lib/loadAndCache.ts` lines 50–57 — where the throw originates:
    ```ts
    } catch (err) {
    if (data) { ... return data; }
    throw new Error(`Failed to fetch ${url} and no cached data available.`);
    }
    ```

Symptom

  • Console pollution: an "Unhandled Promise Rejection: Failed to fetch ... and no cached data available." appears for any package whose first fetch fails (rate limit, network blip, etc.).
  • The card silently never appears, with no user-visible error or retry affordance.

Suggested fix

Add a `.catch` that logs and falls back to a degraded `PackageWithMetadata` (everything from the YAML, with `stars/release/lastUpdated: null`), so the card still renders. Or have `loadPackageMetadata` itself absorb the error and return the same degraded shape it returns when `pkg.githubRepo` is missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions