TanStack / query

🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.
https://tanstack.com/query
MIT License
40.1k stars 2.69k forks source link

fix: replaceDeepEqual for objects created by Object.create #7357

Closed sukovanej closed 1 week ago

sukovanej commented 2 weeks ago

Currently, objects with custom prototypes (created using Object.create(...)) are dealt with as plain objects. That causes them to be copied without the prototype in case of refetch / invalidation and results in buggy behaviour. This is problematic when using together with https://github.com/Effect-TS/effect (e.g Option, Either, ... data structures).

BTW, based on the test suite, it might cover other checks like prot.hasOwnProperty('isPrototypeOf') so the impl of isPlainObject could be refactored a little but I'm honestly not 100% sure.

vercel[bot] commented 2 weeks ago

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

1 Ignored Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **query** | ⬜️ Ignored ([Inspect](https://vercel.com/tanstack/query/Bxp6MV89qaMQJ2w45PjGBh5iVnj6)) | [Visit Preview](https://query-git-fork-sukovanej-fix-replaceequaldeep-o-04722a-tanstack.vercel.app) | | May 4, 2024 8:21am |
codesandbox-ci[bot] commented 2 weeks ago

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 84e38488a5a21b60f8ac8b339a2fd239a20183fb:

Sandbox Source
@tanstack/query-example-angular-basic Configuration
@tanstack/query-example-react-basic-typescript Configuration
@tanstack/query-example-solid-basic-typescript Configuration
@tanstack/query-example-svelte-basic Configuration
@tanstack/query-example-vue-basic Configuration
sukovanej commented 2 weeks ago

This PR should be ready. @TkDodo could you please take a look?

nx-cloud[bot] commented 1 week ago

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 84e38488a5a21b60f8ac8b339a2fd239a20183fb. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target - [`nx affected --targets=test:format,test:sherif,test:knip,test:eslint,test:lib,test:types,test:build,build,test:attw --parallel=3`](https://cloud.nx.app/runs/G4lvtxMmOQ?utm_source=pull-request&utm_medium=comment)

Sent with 💌 from NxCloud.