 
   _compute: ->
     @invalidated = false
-    @_func @
+    inCompute = true
+    try
+      @_func @
+    finally
+      inCompute = false
 
   _recompute: ->
     @_recomputing = true
     while @invalidated and not @stopped
-      try
-        @._compute()
-      catch e
-        console.log e
+      @_compute()
     @_recomputing = false
 
 class Tracker.Dependency

privateObject = {}

nextId = 1
afterFlushCallbacks = []
queue = new Meteor._SynchronousQueue()

_.extend Tracker,
  _currentComputation: new Meteor.EnvironmentVariable()

  flush: ->
    if not queue.safeToRunTask()
      throw new Error("Can't call Tracker.flush while flushing, or inside Tracker.autorun")

    queue.drain()

  _postRun: ->
    while (queue._taskHandles.length == 0) and (afterFlushCallbacks.length > 0)
      f = afterFlushCallbacks.shift()
      try
        f()
      catch e
        console.log "Exception from Tracker afterFlush function:", e.stack || e.message

  autorun: (f) ->
    throw new Error 'Tracker.autorun requires a function argument' unless typeof f is 'function'


  nonreactive: (f) ->
    Tracker._currentComputation.withValue null, f

  onInvalidate: (f) ->
    throw new Error "Tracker.onInvalidate requires a currentComputation" unless Tracker.active
