Skip to content

fix(shared/helpers): don't cache errors in memoize#1070

Merged
sidvishnoi merged 3 commits into
mainfrom
memoize-do-not-cache-errors
Jun 9, 2025
Merged

fix(shared/helpers): don't cache errors in memoize#1070
sidvishnoi merged 3 commits into
mainfrom
memoize-do-not-cache-errors

Conversation

@sidvishnoi

Copy link
Copy Markdown
Member

Context

With getExchangeRatesMemoized, sometimes there was an error in the getExchangeRates call. In that case, the cached result didn't have the expected type, as we had actually cached the rejected promise. So, convertWithExchangeRate was erroring as exchangeRates didn't have .rates.

Noticed while working on #1066.

Changes proposed in this pull request

  • Don't cache promise rejections in memoize.
  • Add tests

Eventually, I think we'll remove the Deduplicator class/service in favor of this helper.

@sidvishnoi sidvishnoi requested a review from DarianM June 9, 2025 13:58
@github-actions github-actions Bot added area: tests Improvements or additions to tests area: shared Changes to shared libraries and utilities labels Jun 9, 2025
@github-actions

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown
Contributor

Extension builds preview

Name Link
Latest commit 38176cb
Latest job logs Run #15536509681
Chrome (991.3KB)Download
Firefox (991.33KB)Download

@sidvishnoi sidvishnoi force-pushed the memoize-do-not-cache-errors branch from 83ee90b to 3857df1 Compare June 9, 2025 14:03
@sidvishnoi sidvishnoi merged commit 41dd6a0 into main Jun 9, 2025
9 checks passed
@sidvishnoi sidvishnoi deleted the memoize-do-not-cache-errors branch June 9, 2025 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: shared Changes to shared libraries and utilities area: tests Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants