2

Ok. I'm using meteor, just meteor, no angular, no ionic. And I've come across some strange behavior: I have a user logged in, and I can log Meteor.user() just fine, it comes back with all the correct properties as per the subscription. However, if I close my laptop, open it, and log Meteor.user() again, I get only the _id and username properties, as if there was no subscription...

Here's my publication code on the server:

Meteor.publish('users', ()=>{
  return Meteor.users.find({},{
    sort:{
      lName:1
    },
    fields:{
      stats: 1,
      skills: 1
    }
  })
})

and my subscription on the client, which may be the problem? It's a tad wonky:

const subs = ['Users', /*Other collections*/].map(a=>Meteor.subscribe(a.toLowerCase(), {
  onReady: function(){console.log(`${a} Loaded:`, arguments)},
  onError: function(){console.log(`${a} Error:`, arguments)},
  onStop: function(){console.log(`${a} Stopped:`, arguments)}
}))

Neither onStop or onError are ever called. onReady calls once when the page is loaded. What is happening to my subscription? I remember once being able to log out all the active subscriptions, but can't remember exactly what it was. Is there a way to prevent this behavior, or a way to work around it? As it stands, my user ends up with no data, which is... unacceptable.

Edit: I was poking around more and more, and I finally found a concrete change in the data. Before I close my lid, Meteor.Users._collection.paused is false. But after, it's true. Mayhap this is a Mongo issue rather than a Meteor issue?

Or Assayag
  • 5,662
  • 13
  • 57
  • 93
Spencer Cornwall
  • 289
  • 2
  • 14
  • 2
    what is closing your lid set to? sleeping? hibernating? – Adassko Nov 18 '20 at 16:57
  • That's an excellent question. It's a macbook pro, and I'm not seeing any equivalent setting to windows' "What happens when you close the lid" After poking around on the internet some more, it puts the hard drive to sleep. – Spencer Cornwall Nov 19 '20 at 17:23
  • It's possible that when the laptop goes to sleep, the DDP connection is lost. I think you need to give it some time to re-establish the subscription. It's like when you first start the subscription, it's not there immediately, but it will run Tracker again once the data arrives. – Mikkel Nov 21 '20 at 05:52
  • Unfortunately, waiting has no effect, and even after I deployed it (thinking it may be a development environment issue) it persists – Spencer Cornwall Nov 21 '20 at 17:39
  • Maybe you should check this : https://stackoverflow.com/questions/43007627/when-i-run-meteor-disconnect-and-then-meteor-reconnect-meteor-clears-minimo – nAviD Dec 26 '20 at 11:55

0 Answers0