Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Structural sharing drops a `__proto__` key from query data and changes the object's prototype

Offen
#12,303 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@Gourav224 arbeitet bereits daran.

Seit 23.10.2026.

  • #12304 von @Gourav224 — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
frontend

Rechercherichtung

The issue identifies replaceEqualDeep and explains how assigning the __proto__ key changes the copy's prototype. Start by locating that function and checking its existing tests for structural sharing. Done means refetching changed data preserves __proto__ as an own property and leaves the result's prototype as Object.prototype; the reporter says they plan to open a PR.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Describe the bug

If query data has a "__proto__" key (JSON.parse keeps it as a normal property), it disappears after a refetch where anything else in that object changed.

replaceEqualDeep builds the new object with copy[key] = value. For __proto__ that assignment calls the setter and changes the copy's prototype instead of adding a property. So the key is gone, and its contents show up as inherited properties instead.

The first fetch is fine, because there is no previous data to share with.

Your minimal, reproducible example
import { replaceEqualDeep } from '@tanstack/query-core'

const prev = JSON.parse('{"__proto__":{"admin":true},"count":1}')
const next = JSON.parse('{"__proto__":{"admin":true},"count":2}')
const result = replaceEqualDeep(prev, next)

Object.keys(result) // ['count']
JSON.stringify(result) // '{"count":2}'
result.admin // true (inherited)
Steps to reproduce
  1. Return JSON with a __proto__ key from a queryFn, for example a map keyed by user input.
  2. Refetch so that some other field in that object changes.
  3. data.__proto__ is no longer an own key, and the object's prototype is now that value.
Expected behavior

__proto__ stays an own property, like any other key, and the prototype stays Object.prototype.

Platform

Any. Reproduced on Node 24.

TanStack Query version

5.104.5 (main)

Additional context

I have a small fix with tests and will open a PR.

Vorherrschende Sprache
TypeScript
Sterne
50.5k
Forks
4.2k
Ø Merge
9 Std. 34 Min.
Gemergte PRs (30 T.)
603

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus TanStack/query

Alle Issues in TanStack/query

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.