我有一个基于Meteor示例'wordplay'的简单游戏.在这里,后台有一个计时器在游戏过程中倒计时.单击"播放"按钮时会调用此计时器.单击按钮时会出现此问题.
服务器端:
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)
Run Code Online (Sandbox Code Playgroud)
客户端:
Template.lobby.events
'click button#startgame': ->
Meteor.call 'start_new_game', current_player()._id
Run Code Online (Sandbox Code Playgroud)
错误:
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
Run Code Online (Sandbox Code Playgroud)
我已经尝试过更改Meteor.setInterval为递归Meteor.setTimeout,但没有改变任何东西.
我尝试过多种浏览器和计算机.