Skip to content

fetchItunesItems Promise.all mapper discards all valid results when one item throws unexpectedly #178

@ooloth

Description

@ooloth

Current state

io/itunes/fetchItunesItems.ts maps API results through Promise.all with per-item null-return handling for validation failures. However, an unexpected throw anywhere inside the mapper body — for example from a failed image transform or schema utility — propagates out of Promise.all, rejects the entire array, and skips the cache.set call. All valid results for all other items in the response are silently discarded, and the cache is left empty for that build.

Ideal state

  • Each mapper body is wrapped in try/catch that returns null on unexpected errors, matching the explicit null-return handling already used for validation failures
  • A single unexpected error for one iTunes item does not cause Promise.all to reject and discard results for all other items
  • The cache is populated with whatever valid results exist even when one item's processing throws

Out of scope

  • Changing the outer try/catch, error reporting structure, or validation logic

Starting points

  • io/itunes/fetchItunesItems.ts lines 97–145 — the Promise.all mapper body where per-item errors need a try/catch fallback

QA plan

  1. Open io/itunes/fetchItunesItems.ts lines 97–145 — confirm the mapper handles explicit validation failures with return null but does not try/catch unexpected throws within the body
  2. After the fix: confirm each iteration of the Promise.all map is wrapped in try/catch that returns null on unexpected errors
  3. In a local build, mock one iTunes result to throw an unexpected error inside the mapper — expect the remaining items are returned and cache.set is called with the valid subset

Done when

An unexpected throw inside the fetchItunesItems Promise.all mapper causes that item to yield null rather than rejecting the entire Promise.all and discarding all other results.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions