Meteor-Community-Packages / Meteor-Community-Packages/ground-db

Can't set timers inside simulations

Open
#88 1 comment 0 reactions 0 assignees View on GitHub
bug investigate
Dominant language
JavaScript
Stars
569
Forks
77
PR merge metrics
No merged PRs in 30d

Description

I'm getting an error which originates from the `_saveDatabase`-function, specifically the
line `self._saveDatabaseTimeout(function() {`:

From the console log:

Error: Can't set timers inside simulations
at withoutInvocation (http://localhost/packages/meteor.js?:433:13)
at bindAndCatch (http://localhost/packages/meteor.js?:441:33)
at Object._.extend.setTimeout (http://localhost/packages/meteor.js?:457:23)
at oneTimeout [ as _saveDatabaseTimeout ] ( http://localhost/packages/raix_onetimeout.js?:47:17 )
**at _saveDatabase (http://localhost/packages/ground_db.js?:548:10)**
at http://localhost/packages/ground_db.js?:193:19
at http://localhost/packages/raix_eventemitter.js?:122:16
at Array.forEach (native)
at Function._.each._.forEach (http://localhost/packages/underscore.js?:156:11)
at _runCallbacks (http://localhost/packages/raix_eventemitter.js?:118:7)

The error occurs when running a method stub on client that contains Tracker.flush().

Meteor.methods({
foo: function (doc) {
collection.insert(doc);
Tracker.flush();
// ...more code...
}});

Contributor guide

Open the contributing guide

Research direction

Start with packages/ground_db.js at _saveDatabase, especially the line calling _saveDatabaseTimeout, and reproduce the issue using a Meteor method stub that inserts a document and calls Tracker.flush(). Read the related raix_onetimeout stack entry to understand the timer path. Done means the reproduction no longer raises the simulation timer error while the database save still occurs correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.