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

payload object is unexpectedly mutated during findAll / findRecord #6758

Closed
Gaurav0 opened this issue Nov 18, 2019 · 1 comment
Closed

payload object is unexpectedly mutated during findAll / findRecord #6758

Gaurav0 opened this issue Nov 18, 2019 · 1 comment

Comments

@Gaurav0
Copy link
Contributor

Gaurav0 commented Nov 18, 2019

Discovered during writing #6754, see comments in the PR.

Description

If you call await store.findRecord('person', 1) and the mock server in your test returns this payload, which is a Plain Old JavaScript Object:

{
  "data": {
    "id": 1,
    "type": "person",
    "attributes: { ... }
  }
}   

then since IDENTIFIERS feature flag was turned on, that payload object was mutated to:

{
  "data": {
    "id": 1,
    "type": "person",
    "lid": "some uuid or other string from generateIdForRecord",
    "attributes: { ... }
  }
} 

Expected Result: Payload object is unchanged, but record returned by findRecord has an added lid.
Actual Result: Payload object is modified to contain an lid.

Note: Fixing this bug may cause a performance regression. Furthermore, users are unlikely to notice this issue outside of testing with a mock server.

Versions

Run the following command and paste the output below: yarn list ember-source && yarn list ember-cli && yarn list ember-data.

yarn list v1.19.0
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ [email protected]
Done in 1.95s.
yarn list v1.19.0
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ [email protected]
Done in 1.99s.
yarn list v1.19.0
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ [email protected]
Done in 2.88s.

(This bug is likely reproducible in the 3.15 beta)

@runspired
Copy link
Contributor

overall this has proved to not be an issue; however, it was a limitation that prevented payloads being fully opaque to the store. emberjs/rfcs#854 addresses this and emberjs/rfcs#860 updates request fulfillment. Collectively they ensure we can thread enough context to the cache that this mutation is no longer necessary.

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

No branches or pull requests

2 participants