Cannot read property 'unchain' of undefined

I have ran into this error a couple times but have hesitated to open an issue because I cannot reduce it to anything that I can build a test for and I’m pretty sure it isn’t really an “issue” just me doing things the wrong way, I know it is because I am observing a capitalized global object’s property. I did chase down where the error is thrown in ember and can hack around it, I’m wondering if anyone can explain what is happening here? I know my hack isn’t a fix and I have restructured to avoid the issue, I’m mostly just curious since I don’t see any side effects because of my hack. I’m sure there are, I just haven’t seen them. :smile:

Changing this:

    ChainNodePrototype.unchain = function(key, path) {
      var chains = this._chains;
      var node = chains[key];

      // unchain rest of path first...
      if (path && path.length>1) {
        key  = firstKey(path);
        path = path.slice(key.length+1);
        node.unchain(key, path);
      }

      // delete node if needed.
      node.count--;
      if (node.count<=0) {
        delete chains[node._key];
        node.destroy();
      }

    };

to this Lets me observe an Ember object in the global space.

    ChainNodePrototype.unchain = function(key, path) {
      var chains = this._chains;
      var node = chains[key];
      if(node) // check if node is undefined.
        {

      // unchain rest of path first...
      if (path && path.length>1) {
        key  = firstKey(path);
        path = path.slice(key.length+1);
        node.unchain(key, path);
      }

      // delete node if needed.
      node.count--;
      if (node.count<=0) {
        delete chains[node._key];
        node.destroy();
      }
      }
    };