Error caught on publication: notes : Can't publish a cursor from a collection without a name

Hi, I’m getting an error when trying to subscribe to my publication.

I’m not quite sure where it’d be coming from, and googling didn’t give much relevant results.

So I have

this collection

export const Notes = new Mongo.Collection('notes');

publication

Meteor.publish('notes', function allNotesPublication () {
  check();
  return Notes.find({}, {fields: {text: 1, _id: 1}});
});

Then I’m subscribing with vue-meteor-tracker

export default {
  data () {
    return {
      newNote: '',
      notes: [],
    }
  },

  meteor: {
    $subscribe: {
      'notes': [],
    },
    notes () {
      return Notes.find({}, {
        sort: { created: -1 },
      })
    },
  },

  methods: {
    async addNote () {
      if (this.newNote) {
        try {
          await Meteor.callPromise('notes.add', {
            text: this.newNote,
          })
          this.newNote = ''
        } catch (e) {
          console.error(e)
        }
      }
    },

    async removeNote (note) {
      try {
        await Meteor.callPromise('notes.remove', {
          _id: note._id,
        })
      } catch (e) {
        console.error(e)
      }
    },
  },
}

When it hits the publication it fails with server error “W20190907-23:34:08.437(2)? (STDERR) error caught on publication: notes : Can’t publish a cursor from a collection without a name.”

My ./meteor/packages:

# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-base@1.4.0             # Packages every Meteor app needs to have
mobile-experience@1.0.5       # Packages for a great mobile UX
mongo@1.6.2                   # The database Meteor supports right now
static-html             # Define static page content in .html files
reactive-var@1.0.11            # Reactive variable for tracker
tracker@1.2.0                 # Meteor's client-side reactive programming library

standard-minifier-css@1.5.3   # CSS minifier run for production mode
standard-minifier-js@2.4.1    # JS minifier run for production mode
es5-shim@4.8.0                # ECMAScript 5 compatibility for older browsers
ecmascript@0.12.4              # Enable ECMAScript2015+ syntax in app code
shell-server@0.4.0            # Server-side component of the `meteor shell` command
akryum:vue-component
aldeed:collection2
aldeed:autoform
akryum:vue-blaze-template
akryum:vue-sass
akryum:vue-ssr
deanius:promise
audit-argument-checks
check

and package.json:

{
  "name": "pvms",
  "private": true,
  "scripts": {
    "start": "meteor run"
  },
  "dependencies": {
    "@babel/runtime": "^7.3.4",
    "core-js": "^3.2.1",
    "meteor-node-stubs": "^0.4.1",
    "simpl-schema": "^1.5.5",
    "vue": "^2.6.10",
    "vue-i18n": "^8.14.0",
    "vue-meteor-tracker": "^2.0.0-beta.5",
    "vue-router": "^3.1.3",
    "vue-template-compiler": "^2.6.10"
  },
  "meteor": {
    "vueVersion": 2
  },
  "devDependencies": {}
}

hope somebody could give a hint…

Looks like your Notes collection has no name. Can you post the code where you declare the collections please.

Sure, please see updated post.

Very weird. Are you getting the error on the server or client?

Yes, that’s on server. I’m trying to find out which package would that be coming from… No clue so far. On the good side publication still seems to work.

I am having the same issue with akryum:vue-ssr. When the server provides the the SSR page I am seeing this error message in the console

The error is actually generated in the meteor/minimongo package _publishCursor(subscription) function.

My hunch is that when using vue-ssr, the server calls this publish function with a LocalCollection instead of the real one, and a local collection does not have a name.

Everything still works, the message is annoying though.

Was actually troubleshooting a different issue and am facing the same problem. @jamgold your hunch is correct I think:

This is from vue-ssr/server/context.js

  getCollection (collName) {
    let collection = this._collections[collName]
    if (!collection) {
      const minimongo = Package.minimongo
      collection = this._collections[collName] = new minimongo.LocalCollection()
    }

    return collection
  }

I will check on how to fix this

Edit
Looking at it, but it seems that FlowRouter has similar code, since its based on that: