Skip to content

Exception while invoking method 'MY_SERVER_METHOD' TypeError: Cannot read property 'collectionViews' of undefined  #5

Open

Description

@trukhilio

Hey, @msavin. Thank you for the fine package!
I updated the meteor to 1.8.1 and received this error.

Exception while invoking method 'MY_SERVER_METHOD_WHICH_USES_METEOR_USER' TypeError: Cannot read property 'collectionViews' of undefined
 at _getCache (packages/msavin_usercache.js:31:39)
 at Object.Meteor.user (packages/msavin_usercache.js:73:15) ...

Inspected a little bit and what I found out:

var connectionData = Meteor.default_server.sessions[connectionId];

is undefined bc Meteor.default_server.sessions object has been changed from {'connectionId': { Session: { collectionViews: { ... }}}} to Map { 'connectionId' => Session { ... }} and now we have to get the value like

Meteor.default_server.sessions.get(connectionId);

And new method wouldn't work for previous meteor 1.8.
Hope this info will help you.

Activity

  1. RomainSennat commented on May 17, 2019

    @RomainSennat

    Same problem for me.
    I've submit a pull request to fix this yesterday.

    #6

  2. wildhart commented on Jun 4, 2019

    @wildhart

    I'm still getting the odd instance of this error, even with the latest patch. I'm using peerlibrary:reactive-publish and I suspect the error only occurs occasionally when a user either logs out or closes the tab.

    error

    I might try inserting a line:

    var connectionData = isMeteor1_8 ? Meteor.default_server.sessions.get(connectionId) : Meteor.default_server.sessions[connectionId];
    if (!connectionData) return result;
    var collectionViews = isMeteor1_8 ? connectionData.collectionViews.get('users').documents.get(instance.userId) : connectionData.collectionViews.users.documents[instance.userId];

    Also, the pedant in me wants to move the var isMeteor1_8 = Meteor.release.match('1.8') !== null; outside of _getCache() so that it's only done once!

  3. added a commit that references this issue on Jun 8, 2019
    dab4b06
  4. trukhilio commented on Jun 16, 2020

    @trukhilio
    Author

    Hi, I updated meteor to 1.10.2 and this bug appears again, maybe it's because it's match to 1.8 and not gte 1.8

  5. wildhart commented on Jun 16, 2020

    @wildhart

    It appears that this package is abandoned. I anticipated this issue with Meteor 1.10 a year ago but PR hasn't been merged yet. You could copy my fork into your packages folder.

    From my fork which explains this issue:

    // check meteor version.  Be forwards compatible for future major and minor versions also.
    // Note that 1.10 < 1.8 so need to convert to 110 and 108 for comparison
    var isMeteor1_8 = Meteor.release.match(/(\d+)\.(\d+)/);
    isMeteor1_8 = (isMeteor1_8[1]*100 + isMeteor1_8[2]*1) >= 108;
    

    Or you could replace it with my newer package wildhart:mergebox-cache which works on all collections, not just Meteor.users.

  6. trukhilio commented on Jun 16, 2020

    @trukhilio
    Author

    @wildhart thank you! Will try your package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions