Angular-Meteor 1 helper: Error: Item xxxxxx already present in OrderedDict


#1

Hey guys,

I have this issue on my app but I’ve been able to reproduce it on the completed angularjs meteor tutorial found here https://www.meteor.com/tutorials/angular/creating-an-app

Exception in queued task: Error: Item 5a395ec67e5d23beb3ce21c7 already present in OrderedDict
    at OrderedDict.putBefore (http://localhost:3000/packages/ordered-dict.js?hash=bacdd1852075630a01f7de783e5e8e8aa8541cdc:105:13)
    at Object.addedBefore (http://localhost:3000/packages/minimongo.js?hash=2b34314db9dbc6027d9d414887b75281c4515a19:2858:23)
    at http://localhost:3000/packages/minimongo.js?hash=2b34314db9dbc6027d9d414887b75281c4515a19:1821:16
    at Meteor._SynchronousQueue.SQp.runTask (http://localhost:3000/packages/meteor.js?hash=cbcc712d51de4298c275e8dcf25c66c29914f19a:782:9)
    at Meteor._SynchronousQueue.SQp.flush (http://localhost:3000/packages/meteor.js?hash=cbcc712d51de4298c275e8dcf25c66c29914f19a:811:8)
    at Meteor._SynchronousQueue.SQp.drain (http://localhost:3000/packages/meteor.js?hash=cbcc712d51de4298c275e8dcf25c66c29914f19a:820:10)
    at Cursor.observeChanges (http://localhost:3000/packages/minimongo.js?hash=2b34314db9dbc6027d9d414887b75281c4515a19:1872:37)
    at Function.LocalCollection._observeFromObserveChanges (http://localhost:3000/packages/minimongo.js?hash=2b34314db9dbc6027d9d414887b75281c4515a19:3467:23)
    at Cursor.observe (http://localhost:3000/packages/minimongo.js?hash=2b34314db9dbc6027d9d414887b75281c4515a19:1737:30)
    at Scope.$$Reactive.$$handleCursor (http://localhost:3000/packages/modules.js?hash=2d2320e0a085f73525ac71db465a229bf55532bb:37642:31)

All I’ve done is added an input field in the template and take it as a regex in the helpers, as below:

    this.helpers({
      tasks() {
        const selector = {};

        if (this.getReactively('text')) {
          selector.text = {
            $regex: '.*'+this.text+'.*',
            $options: 'i'
          };
        }

        return Tasks.find(selector, {
          sort: {
            createdAt: -1
          }
        });
      },
...

So as you fill the text field the correct results are returned. The error occurs when you empty the text field. I could stick it into a method but that would lose the reactivity aspect.

If you could help it’d be greatly appreciated!