Error: You can't use reactive data sources like Session inside the `.subscriptions` method!

This happens for my frontend app (which was for the most part written by another developer).

Can someone tell me where should I look for the source of this error?

This is what MontiAPM recorded:

Error: You can't use reactive data sources like Session inside the `.subscriptions` method!
    at meteor://desktop/__cordova/f11480db9b800d5b39514adfe7187b7e1284bf71.js?meteor_js_resource=true:298:6475
    at t (meteor://desktop/__cordova/f11480db9b800d5b39514adfe7187b7e1284bf71.js?meteor_js_resource=true:143:2705)
    at t.o.Computation._compute (meteor://desktop/__cordova/f11480db9b800d5b39514adfe7187b7e1284bf71.js?meteor_js_resource=true:312:14710)
    at t [as _recompute] (meteor://desktop/__cordova/f11480db9b800d5b39514adfe7187b7e1284bf71.js?meteor_js_resource=true:143:2932)
    at Object.c._runFlush (meteor://desktop/__cordova/f11480db9b800d5b39514adfe7187b7e1284bf71.js?meteor_js_resource=true:143:4228)
    at Object.o._runFlush (meteor://desktop/__cordova/f11480db9b800d5b39514adfe7187b7e1284bf71.js?meteor_js_resource=true:312:14262)
    at a (meteor://desktop/__cordova/f11480db9b800d5b39514adfe7187b7e1284bf71.js?meteor_js_resource=true:1:3222)

My frontend is an Electron app build with the Meteor-desktop package.

As much as I can tell this is happening in more than one route. In this case it was:


but I’ve also seen at least one other (this is the main screen of our app though).

Thanks in advance!

Are you using react-meteor-data package?

Also, did you checked this thread? ReactiveVars in subscriptions with FlowRouter - #4 by arunoda maybe there is something that can be helpful

No, not using it. We’re using Blaze.

Thanks for the link, will check it out

I’ve got more information from the log file this time @hschmaiske

Exception from Tracker recompute function:

Error: You can't use reactive data sources like Session inside the `.subscriptions` method!
    at kadira_flow-router.js:588
    at Computation._compute (tracker.js:362)
    at Computation.Tracker.Computation._compute (montiapm_agent.js:1323)
    at Computation._recompute (tracker.js:387)
    at Object.Tracker._runFlush (tracker.js:589)
    at Object.Tracker._runFlush (montiapm_agent.js:1285)
    at onGlobalMessage (meteor.js:552)

It seems (guessing here) it’s happening at this function:

Accounts.validateLoginAttempt((options) => {

But I find the error message highly misleading. I’m not using Sessions nor is it in a subscriptions method.

So I’m still completely lost as to where this error is coming from and more importantly, what needs to be changed. The article from Arunoda didn’t help me, I might just understand too little about the intricacies of Meteor frontend :frowning:

Is there a way to reproduce it? You could create a repository to isolate the problem, so we could understand what is going on.

It happens in my production app (which is an Electron app), so unfortunately no way I can create a repository.

As I wrote, I’m not even 100% sure it is happening in that function.

Also, it isn’t reproducible at all times. I’ve got it only on the first start of the Electron app, it seems to be related to a yet unknown (Race ?) condition where it calls the login function before the user has entered any details (very early in the Startup process it seems).

Only then it throws the error. As the above call to Accounts.validateLoginAttempt is coming from the Meteor Accounts package I’m not sure where it originates from and when it’s being why (nor why it’s sometimes fired too early as there’s clearly nothing to validate when they user didn’t even had the chance to enter something).

Not sure if these observations help you but I hope. Thanks!

It seems it happens only when the following conditions are fulfilled in the Accounts.validateLoginAttempt((options) => function:

if (options.allowed === false || options.user === undefined) {