derbyjs / racer

Realtime model synchronization engine for Node.js
1.18k stars 116 forks source link

Fix reference to this in _maybeUnloadDoc inner function #277

Closed ericyhwang closed 4 years ago

ericyhwang commented 4 years ago

The inner function was introduced in introduced in a320772 (PR https://github.com/derbyjs/racer/pull/276).

I missed changing a this to model.

I'll look into adding a test later, I want to get this fix out quickly.


This can cause an error like TypeError: Cannot read property '$remote' of undefined in listeners that are checking properties the pass object.

Stack trace will have a snippet like this:

  at Model.emit [as _emit] (events.js:203:15)
  at Model.emit (.../node_modules/racer/lib/Model/events.js:99:10)
  at unloadDoc (.../node_modules/racer/lib/Model/subscriptions.js:197:11)
  at Model._maybeUnloadDoc (.../node_modules/racer/lib/Model/subscriptions.js:186:5)
  at finishUnfetchDoc (.../node_modules/racer/lib/Model/subscriptions.js:127:11)
  at Model.unfetchDoc (.../node_modules/racer/lib/Model/subscriptions.js:122:5)
  at Model._forSubscribable (.../node_modules/racer/lib/Model/subscriptions.js:66:24)
  at Model.unfetch (.../node_modules/racer/lib/Model/subscriptions.js:21:8)
ericyhwang commented 4 years ago

Fix published in https://github.com/derbyjs/racer/releases/tag/v0.9.13