0

I'm having trouble debugging an onAfterAction that I don't want to run. It happens when I click a certain div. Router.go is not being called (verified with debugger; in the iron router code), and the URL is not changing. I can't find anything in my click handlers that would cause a route change. The onAfterAction happens from a deps invalidation:

Router.configure.onAfterAction (routes.coffee:5)
RouteController.runHooks (route_controller.js:155)
(anonymous function) (route_controller.js:291)
RouteController.runHooks (route_controller.js:158)
(anonymous function) (route_controller.js:283)
Deps.Computation._compute (deps.js:196)
Deps.Computation._recompute (deps.js:210)
Deps.flush (deps.js:304)
Loren
  • 11,184
  • 6
  • 40
  • 67

2 Answers2

1

Probably you have some reactive data source in onAfterAction (cursor, Session object). It will rerun every time reactive data source will be changed.

You can forbid this behavior by wrapping function in onAfterAction :

Tracker.nonreactive(function(){})
Kuba Wyrobek
  • 5,273
  • 1
  • 22
  • 26
  • Thanks, tried that, but the problem remains. Any suggestions for further diagnosis? – Loren Sep 17 '14 at 22:21
  • @KubaWyrobek i tried your approach but it didn't work for me. I'm using Tracker.afterFlush(function () {}). i also changed the Meteor.user() to Meteor.userId(). View getting loaded but url not get flushed. – Shrinath Mar 21 '16 at 10:45
0

Clicking the div caused the User doc to change. There was global onBeforeAction that checked to see if the user was logged in (if Meteor.user()), which is reactive and triggered a rerun of action and onAfterAction. I changed it to if Meteor.userId(), which did not get invalidated when updating the user doc.

Loren
  • 11,184
  • 6
  • 40
  • 67