Skip to content

Instantly share code, notes, and snippets.

@DingoEatingFuzz
Last active April 4, 2018 18:39
Show Gist options
  • Save DingoEatingFuzz/dd3f94e44dc7f36185c9b78a238e5ca2 to your computer and use it in GitHub Desktop.
Save DingoEatingFuzz/dd3f94e44dc7f36185c9b78a238e5ca2 to your computer and use it in GitHub Desktop.
Ember Data duplicate record in hasMany bug report

Duplicate Records make it into the store

This occurs in Nomad UI, an open source ember app: https://github.com/hashicorp/nomad/tree/master/ui

Summary

Fetching related data in the right order under unknown circumstances will push a copy of an existing record instead of updating the existing record.

Steps to Reproduce

  1. Start on the clients page This will fetch /nodes and /nodes/node-1 and /node/node-1/allocations To display the list nodes, the details for each node, and the count of allocations for each node.
  2. Go to the jobs page This will fetch /jobs to list all jobs
  3. Go to job-1 This will fetch a lot of related data for the job, including /job/job-1/allocations. The allocations for the job overlap with the allocations for the node, since allocations belong to a job and run on a node.
  4. Inspect the state of node-1 It will now have one more allocation than before, due to the overlapping allocation in the /job/job-1/allocations reponse appending to the node allocations hasMany rather than updating it.
  5. Inspect the state of peekAll('allocation') The store has the correct number of allocations. The errant duplicate is local to only the node's relationship state.

API & Relationship Details

Data Fetching Details

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