-
Notifications
You must be signed in to change notification settings - Fork 649
Watchers fired in the last x iterations #433
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
Comments
I get these as well, and they grow exponentially as the size of the schema grows. If I start cutting down the schema, I reach a point that the errors go away, but it's a pretty small schema at that point, with maybe 20 properties at most. |
Please add a gist or plunkr so it can be easily debugged. |
I've moved on from trying to use this library, so I won't have anything to add, maybe the OP can |
Oh, that is too bad. ASF is really going places now. |
I am facing a similar issue. So, I am setting form values inside an ajax call. The form basically contains some drop downs which in turn are populated by a service created in angular. Plane javascript function has been written which takes some parameters and gets the relevant drop down values. And then in my view I am utilising the schema form like this. The values have been set on rootScope so don`t worry about the $root part in the tag. Now, the sf-schema attribute gives me [$rootScope:infdig] error. I have tried removing it and it doesn`t give me the error. If I keep it the ajax calls just die. I cannot give you a plnkr for it and I also cannot provide you the actual code as well. But see if you can help. I also tried $rootScopeProvider.digestTtl(400) but it works some time and some time it doesn`t. And it has performance issues as well. |
It is very difficult to find out what is the problem from descriptions like this. That said, I would perhaps recommend you to chain the $http.get's, they may happen in any order as it is now, and perhaps that causes problems with the rest of your code, but I don't know. |
With chaining i mean: $http.get('app/questionnaire/schema.json').success(function(resschema) {
console.log(resschema);
$scope.schema = resschema;
$http.get('app/questionnaire/form.json').success(function(resform) {
console.log(resform);
$scope.form = resform;
});
}); |
@nicklasb do you have a working plunkr i can fork to recreate the issue for you? I don't have time to get all the dependencies pulled in to replicate the issue, but I do have a simple working test case |
@nikmartin, no I don't actually, not with ASF. However that is something that would be good for the project to have, feel free to create a baseline ASF plunkr, and we can use that to create an official one to use in cases like this. |
Found this, not sure how relevant the source is, but you could just copy/paste from ASF. |
This demonstrates the isse: |
Well, that is a huge schema. var agencySchema = {
'id': 'https://app.nitropcr.com/api/schema/agency',
'$schema': 'http://json-schema.org/draft-04/schema#',
'title': 'NitroPCR Agency Schema',
'type': 'object',
'properties': {
'_id': {
'type': 'string'
},
}
}; .. and the full schema. (removed the ", 'object']" as that doesn't generate any form input in ASF) |
ALso, feel free to add this plunker to the readme: https://plnkr.co/edit/5F0Gu1?p=preview It's a plunker of the demo that's in the readme. |
I'm not sure I understand. If the error is purely related to the size of the schema, then I'm not sure how to proceed, as the size of the schema is what it is. The schema itself is a valid json-schema (v4) |
I am suggesting not that the size is the issue, but some construct within
|
I was able to continue with my task by adding this to my app:
So @PierrickI3, in your case, try:
The default digestTtl is 10, and something is triggering this, so bumping it by 5 fixed it for me in my VERY LARGE schema. This probably isn't a permanent fix, but at least I can continue without so many errors. I don't understand all the ramifications of doing this, but here's the docs for it: https://docs.angularjs.org/api/ng/provider/$rootScopeProvider |
@nikmartin, I just saw the plunkr, it looks great! Ok. I would say that this is a difficult one. Obviously, loads of watchers are created when a huge schema like this is loaded, so it actually may be a permanent fix. |
Yes, we use MOST of the features of json-schema v4, so there may be some edge cases that are tripping it. We use regex pattern: {} validation functions, in the form of format: {} properties, etc. |
Hm. It seems to be a plain complexity issue. If I remove the regex patterns, the error doesn't happen during initialisation. However it happens later on, when I navigate the form instead. |
I think that perhaps some others should take a look at this issue and decide if there is anything to do here, @davidlgj , perhaps. |
@nikmartin @nicklasb there are way too many watchers in the current bootstrap decorator in the name of flexibility, with the Material repo I made a number of values like title a one-way bind and more than halved the number of watchers. I suspect the same changes need to occur in the bootstrap repo. Otherwise as soon as you set all those values you trigger the watchers. A bugfix issue needs to be added to the bootstrap decorator, it could be a breaking change for some use cases. But I think it would certainly help the situation. |
Ok, good that there seems to be an explanation. |
The new alpha would be good to get some feedback on regarding the issues here. If it is still worthwhile documenting the work around then @nicklasb can certainly look at updating that :) |
Updated to use the latest version |
Added example plunker, thanks to @nikmartin in #433 here is a demo plunker you can use as a starting point https://plnkr.co/edit/C9mM5feGGZ0N7povA84G?p=preview
I believe this is fixed in the latest updates (alphas) for the eventual 1.0.0 release. ps. @nikmartin I added the plunker to the create issue template and will try to remember to add to documentation soon, cheers :) |
I am getting some angular errors when using the following code. The script seems to work but I would like to suppress these errors. Could you help me find out what is going on?
Controller:
questionnaire.html:
form.json:
schema.json:
Error:
The text was updated successfully, but these errors were encountered: