Meteor 流星计时器上升';RangeError:超过最大调用堆栈大小';

Meteor 流星计时器上升';RangeError:超过最大调用堆栈大小';,meteor,Meteor,我有一个基于流星的简单游戏示例“文字游戏”。在这里,有一个计时器在后台倒计时在游戏过程中。单击“播放”按钮时调用此计时器。单击按钮时会出现问题 服务器端: start_new_game: (player_id) -> # check player_id return unless player_id # TODO: Avoid getting the same questions questions = Questions.find({}, {limit: 5}).fetch() g

我有一个基于流星的简单游戏示例“文字游戏”。在这里,有一个计时器在后台倒计时在游戏过程中。单击“播放”按钮时调用此计时器。单击按钮时会出现问题

服务器端:

start_new_game: (player_id) ->

# check player_id
return unless player_id

# TODO: Avoid getting the same questions
questions = Questions.find({}, {limit: 5}).fetch()

game_id = Games.insert
  current_points: START_POINTS
  current_question: 1
  question_ids: questions.map (q) -> q._id
  time_per_question: TIME_PER_QUESTION

Players.update({ _id: player_id },
  { $set: { game_id: game_id } }
)

points_per_question = START_POINTS / NUMBER_OF_QUESTIONS
points_per_second   = points_per_question / TIME_PER_QUESTION

clock = TIME_PER_QUESTION

# BOOM: Comment following line removes problem
unless interval then interval = setInterval((-> console.log 'COMON'), 1000)
客户端:

Template.lobby.events 
  'click button#startgame': ->
    Meteor.call 'start_new_game', current_player()._id
错误:

W2040-19:15:24.798(1)? (STDERR) /Users/markus/.meteor/tools/0b2f28e18b/lib/node_modules/fibers/future.js:173
W2040-19:15:24.800(1)? (STDERR)                         throw(ex);
W2040-19:15:24.802(1)? (STDERR)                               ^
W2040-19:15:24.803(1)? (STDERR) RangeError: Maximum call stack size exceeded
=> Exited with code: 8
我尝试将Meteor.setInterval更改为递归的Meteor.setTimeout,但没有更改任何内容

我在多个浏览器和计算机中进行了尝试。

根据:

在服务器上调用方法定义可以调用的函数 由客户端远程执行。它们应该返回一个EJSON可调用的值或抛出 例外

您的CoffeeScript代码隐式返回了一个区间句柄,我认为这是将EJSON解析器放入tailspin中。如果您只返回任何其他内容(使用任何其他表达式结束您的方法),它可能会正常工作。

根据:

在服务器上调用方法定义可以调用的函数 由客户端远程执行。它们应该返回一个EJSON可调用的值或抛出 例外


您的CoffeeScript代码隐式返回了一个区间句柄,我认为这是将EJSON解析器放入tailspin中。如果您只返回任何其他内容(用任何其他表达式结束您的方法),它可能会工作得很好。

哇,这是一个很好的捕获!非常感谢。不幸的是,这个错误被其他错误所取代。我会马上更新这个问题的,它就不见了。一切都很顺利。再次感谢!哇,这是个好机会!非常感谢。不幸的是,这个错误被其他错误所取代。我会马上更新这个问题的,它就不见了。一切都很顺利。再次感谢!