Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: stubFence cannot lock #133

Closed
TomBrouws opened this issue Nov 20, 2015 · 6 comments
Closed

Error: stubFence cannot lock #133

TomBrouws opened this issue Nov 20, 2015 · 6 comments

Comments

@TomBrouws
Copy link

I'm developing an application which uses ground:db to ensure no data is lost when the app is offline. When testing, I noticed that when leaving the app open all methods resume fine, but when I close the tab in Chrome when offline and open it again when online, the methods aren't resumed and I get the following error:
Exception in setTimeout callback: Error: stubFence cannot lock since another stubFence is running at _DDP.stubFence (http://localhost:5000/packages/raix_stubfence.js?c21ef205f1a9abdb7017f81e3d264d153d4ec916:70:11) at eachWaitingMethods (http://localhost:5000/packages/ground_db.js?04a81d36d3ec255367d52a6cc18983233c5992d4:803:34) at Array.forEach (native) at Object._.each._.forEach [as each] (http://localhost:5000/packages/underscore.js?fa590de5090ceb4a42555b48562fd8f8e7035758:157:11) at resumeWaitingMethods (http://localhost:5000/packages/ground_db.js?04a81d36d3ec255367d52a6cc18983233c5992d4:788:15) at loadMissingMethods (http://localhost:5000/packages/ground_db.js?04a81d36d3ec255367d52a6cc18983233c5992d4:860:7) at storageLoadMissingMethods (http://localhost:5000/packages/ground_db.js?04a81d36d3ec255367d52a6cc18983233c5992d4:847:5) at Store.localStorage.getItem (http://localhost:5000/packages/ground_localstorage.js?89b38571d614dd46fea10ebc05d0ad97d4ae3c2e:233:7) at loadMissingMethods (http://localhost:5000/packages/ground_db.js?04a81d36d3ec255367d52a6cc18983233c5992d4:835:19) at _loadMethods (http://localhost:5000/packages/ground_db.js?04a81d36d3ec255367d52a6cc18983233c5992d4:854:3)

I'm not sure if this error is in my setup or related to the package.

@Endtry
Copy link

Endtry commented Dec 28, 2015

Hello, I am having the exact issue. Is there a resolution for this? Thanks!

@tadruj
Copy link

tadruj commented Mar 4, 2016

Possibly a corrupted local storage. Remove everything with the GrounDB key.

@introrse
Copy link

The same error in Safari is:
Exception in setTimeout callback: stubFence@http://192.168.1.72:3000/packages/raix_stubfence.js?c21ef205f1a9abdb7017f81e3d264d153d4ec916:70:20

In both Safari and Chrome it seems to be called by not initializing at exactly the right time with Ground.methodResume at startup, then later correctly calling Ground.methodResume on the method in question, then invoking that method while disconnected (such that it ought to be cached), then quitting the browser with cached method invocations still pending. Upon startup, the error is thrown.

The error goes away if you clear just the method storage key/value pair: (meaning you don't need to remove not everything) But unfortunately this also discards any pending method
localStorage.removeItem('_storage._methods_.db.methods')

If you haven't found another work-around, try changing how you use Ground.methodResume. Especially, make sure you call it with an array -- NOT with an iterator (e.g., _.each) or similar

@introrse
Copy link

In particular, this code block causes the error in our app for "method18" invocations:
_each.(['method1', 'method2', ..., 'method18'], Ground.methodResume)

But replacing this block with any one of the following avoids the error
Ground.methodResume('method18') (just one method)
Ground.methodResume(['method1','method2',...,'method18']) (pass array)
_each.(['method18'], Ground.methodResume ) (same as failing code, but only 1 method listed)
_each.(['method1', 'method2', ..., 'method18'], function(n) { Ground.methodResume(n); }) (local fn)

The best I can come up with so far is that it's a very subtle ordering/timing bug which the four methods at the end disturb positively, perhaps in different ways.

@raix
Copy link

raix commented Apr 6, 2016

I've released 2.0.0-alpha.1 Notes about the new version, migration and what it doesn't do - The issue might be resolved in that version, let me know what you think

@ghost
Copy link

ghost commented Jul 1, 2016

As for the exceptions mentioned above. For me this errors disappeared when I put the Ground.methodResume()into the /lib/ folder. Maybe it just needs to be called in the very beginning?
And with an array [], not _.each(), and inside Meteor.isClient.
Also I just found out that this problem can be caused from accidentally putting Meteor.methods({})calls on the server into a Meteor.startup(..})function.
And also if Methods are only defined on the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants