ebryn / ember-model

A lightweight model library for Ember.js
MIT License
526 stars 162 forks source link

Fix concurrency bug when fetching and creating models simultaneously. #487

Closed adriancooney closed 10 months ago

adriancooney commented 5 years ago

This PR fixes a bug we've encountered where Model.create will fail if there is an in-progress findAll. If fails with the following error (for future Googlers):

TypeError: Cannot read property 'replace' of null
    at o.replaceContent (vendor.js.gz:3749)
    at o.replace (vendor.js.gz:3749)
    at o.insertAt (vendor.js.gz:3704)
    at o.pushObject (vendor.js.gz:3704)
    at o.addObject (vendor.js.gz:3717)
    at Function.addToRecordArrays (vendor.js.gz:8109)
    at o.didCreateRecord (vendor.js.gz:8067)
    at VM6860 Script snippet %2311:13

The fix was fairly simple. We set the content of the temporary _findAllRecordArray to have a default content so that when we attempt to push into the record array, it does not fail.

Notes: