Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cache select errors #3554

Merged
merged 1 commit into from
May 1, 2022
Merged

Conversation

TkDodo
Copy link
Collaborator

@TkDodo TkDodo commented Apr 24, 2022

refs #3530

there is no need to re-run the select function if it is referentially stable, even when it throws an error. if no dependency has changed, we can re-use the cached error, as the select function should be idempotent and thus return the same error anyway.

further, if we have cached data from a previously successful select, that should be returned as data alongside the error.

there is no need to re-run the select function if it is referentially stable, even when it throws an error. if no dependency has changed, we can re-use the cached error, as the select function should be idempotent and thus return the same error anyway.

further, if we have cached data from a previously successful select, that should be returned as `data` alongside the error.
@vercel
Copy link

vercel bot commented Apr 24, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
react-query ✅ Ready (Inspect) Visit Preview Apr 24, 2022 at 7:53AM (UTC)

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 4d1bcef:

Sandbox Source
tannerlinsley/react-query: basic Configuration
tannerlinsley/react-query: basic-typescript Configuration

@codecov
Copy link

codecov bot commented Apr 24, 2022

Codecov Report

Merging #3554 (4d1bcef) into master (07c9ce0) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3554      +/-   ##
==========================================
- Coverage   96.35%   96.35%   -0.01%     
==========================================
  Files          45       45              
  Lines        2278     2277       -1     
  Branches      637      637              
==========================================
- Hits         2195     2194       -1     
  Misses         80       80              
  Partials        3        3              
Impacted Files Coverage Δ
src/core/queryObserver.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 07c9ce0...4d1bcef. Read the comment docs.

@TkDodo
Copy link
Collaborator Author

TkDodo commented Apr 24, 2022

working forked sandbox from the discussion with the preview build: https://codesandbox.io/s/error-logging-forked-jp52dv?file=/src/App.jsx

@TkDodo TkDodo merged commit 09a375b into TanStack:master May 1, 2022
@TkDodo TkDodo deleted the feature/cache-select-errors branch May 1, 2022 20:36
@tannerlinsley
Copy link
Collaborator

🎉 This PR is included in version 3.38.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

MMMikeM pushed a commit to MMMikeM/react-query that referenced this pull request May 23, 2022
there is no need to re-run the select function if it is referentially stable, even when it throws an error. if no dependency has changed, we can re-use the cached error, as the select function should be idempotent and thus return the same error anyway.

further, if we have cached data from a previously successful select, that should be returned as `data` alongside the error.
@tannerlinsley
Copy link
Collaborator

🎉 This PR is included in version 4.0.0-beta.14 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants