Skip to content

[4.12.3] Bug: Loading / unloading the same resource multiple times results in lingering reference in cache #8924

@brian-dead

Description

@brian-dead

Reproduction

Diff from ember-cli blueprint

git clone [email protected]:bk-pb/data-multiple-unload.git
cd data-multiple-unload
npm i
ember s

NOTE: Do not open Ember Inspector before receiving the error. Having it open on the Data tab during reproduction seems to hide the issue.

  1. Open http://localhost:4200/home
  2. Navigate to Company List
  3. Notice that @model.length is 2
  4. Navigate to Home
  5. Navigate to Company List again
  6. Notice that @model.length is still 2
  7. Navigate to Home
  8. Navigate to Company List again
  9. Notice that @model.length is now 4 and an error is thrown:
index.js:153 Uncaught (in promise) Error: Assertion Failed: Expected to receive a stable Identifier to subscribe to
    at assert (index.js:153:1)
    at NotificationManager.subscribe (index-36c7ac56.js:3571:1)
    at new RecordState (has-many-c1bfdebf.js:3242:1)
    at CompanyModel.init [as _super] (has-many-c1bfdebf.js:3626:1)
    at CompanyModel.init (has-many-c1bfdebf.js:5503:1)
    at CompanyModel.superWrapper (index.js:366:1)
    at initialize (core.js:74:1)
    at CompanyModel.create (core.js:398:1)
    at Store.instantiateRecord (index-36c7ac56.js:5529:1)
    at InstanceCache.getRecord (index-36c7ac56.js:2953:1)

Description

Loading / unloading the same resource (i.e. record with the same type and id) multiple times results in lingering record reference in cache, which triggers a missing stable identifier error on any subsequent peeks.

Upgrading from 3.24.2 to 4.12.3. Quite a jump, but it feels like this use case is simple enough that it shouldn't be blowing up like this.

Versions

Ember: 4.12.3
Ember Data: 4.12.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions