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

[BUG] Duplicate Module Loading #84

Closed
amcdnl opened this issue Nov 5, 2014 · 19 comments
Closed

[BUG] Duplicate Module Loading #84

amcdnl opened this issue Nov 5, 2014 · 19 comments
Labels

Comments

@amcdnl
Copy link

amcdnl commented Nov 5, 2014

I'm using AngularJS 1.3.0 ( 1.3.1 has same issue too ) but I'm getting modules loading duplicate times, causing things to randomly break.

Citing errors like:

Error: [$compile:multidir] Multiple directives [dropdownFilter, dropdownFilter] asking for template on: <dropdown-filter ng-model="report.filters" available="filterable" class="ng-pristine ng-untouched ng-valid">
http://errors.angularjs.org/1.3.1/$compile/multidir?p0=dropdownFilter&p1=dropdownFilter&p2=template&p3=%3Cdropdown-filter%20ng-model%3D%22report.filters%22%20available%3DNaNilterable%22%20class%3D%22ng-pristine%20ng-untouched%20ng-valid%22%3E
    at http://windows.local/swimlane-local/bower_components/angular/angular.js:80:12
    at assertNoDuplicate (http://windows.local/swimlane-local/bower_components/angular/angular.js:7861:15)
    at applyDirectivesToNode (http://windows.local/swimlane-local/bower_components/angular/angular.js:7312:11)
    at http://windows.local/swimlane-local/bower_components/angular/angular.js:7787:37
    at processQueue (http://windows.local/swimlane-local/bower_components/angular/angular.js:12901:27)
    at http://windows.local/swimlane-local/bower_components/angular/angular.js:12917:27
    at Scope.$eval (http://windows.local/swimlane-local/bower_components/angular/angular.js:14110:28)
    at Scope.$digest (http://windows.local/swimlane-local/bower_components/angular/angular.js:13926:31)
    at Scope.$apply (http://windows.local/swimlane-local/bower_components/angular/angular.js:14214:24)
    at done (http://windows.local/swimlane-local/bower_components/angular/angular.js:9474:47) 

I was able to narrow down its the reloading issue by adding an if statement around the module invoking only allowing new modules to be loaded. http://www.screencast.com/t/7KhVbZtVlgze

Additionally, if you turn on the debugger you can see the logging invoking it twice. Heres my output displaying the error above: http://www.screencast.com/t/uYnfahFkl

@ocombe
Copy link
Owner

ocombe commented Nov 5, 2014

Probably a duplicate of #77
I suppose that you use the last version too ?
Any chance to have a plunkr ?

@amcdnl
Copy link
Author

amcdnl commented Nov 5, 2014

Yes, on latest.

A plunker would be a mighty undertaking given module complexity I showed. I'll see what I can do but any ideas on your part?

@ocombe
Copy link
Owner

ocombe commented Nov 5, 2014

If you use requireJS I'm guessing that you use Angular.bootstrap.
If that's the case you need to tell $ocLazyLoad the name of you main module so that the lib can build the dependency tree (and the preloaded modules). See this.

@amcdnl
Copy link
Author

amcdnl commented Nov 5, 2014

Yes, I already do this.

@vlad-nica
Copy link

Encountered same problem. You can see it here: http://deiweb.net/ocLazyLoad/
Just navigate back & forth between home page & users.
This problem appeared after I added a lazy load in the first page.

@amcdnl
Copy link
Author

amcdnl commented Nov 9, 2014

bower bump plz :)

@ocombe
Copy link
Owner

ocombe commented Nov 9, 2014

Yes, I'm fixing another bug and I'll do that right after (today)

@ocombe ocombe added bug and removed Need to check labels Nov 9, 2014
@ocombe
Copy link
Owner

ocombe commented Nov 9, 2014

0.3.10 has been released !

@amcdnl
Copy link
Author

amcdnl commented Nov 10, 2014

This did not fix my issue :(

@ocombe
Copy link
Owner

ocombe commented Nov 10, 2014

You have the bug with 0.4.2 ? Well I'm gonna need a code sample to find out the bug...

@amcdnl
Copy link
Author

amcdnl commented Nov 10, 2014

Yup in 0.4.2

So I believe this is the scenario: 'core' loads the 'components.toolbar' then 'AppBuilder' reloads it; injecting it twice.

http://www.screencast.com/t/4xuGImxuAv0W

@ocombe
Copy link
Owner

ocombe commented Nov 10, 2014

The lib should only allow one directive of the same name per module. In your case it would store the following definition:

{
  'components.toolbar': {
    'directive': ['toolbar']
  }
}

This way, you can't register the same directive name twice for the same module.
With the bug before 0.3.10, it could say that a directive was new and needed to be invoked because it was detected as already loaded (yeah, stupid bug).
Now it is not possible (or shouldn't).

The only reason why you might have this bug was if you had two directives toolbar defined in two different modules and doing the same thing. And I assume that it is not the case here.

That's why I need to take a look at your code to reproduce the bug and fix it. Make me a plunkr, or a live web site, or send me the code by mail (olivier.combe@gmail.com) if you don't want it to be public.
At least give me a sample of the code (I don't need the full code, just enough to be able to reproduce this error).
If you don't, I don't see how I could fix it until I stumble on it myself. Sorry.

@ocombe ocombe reopened this Nov 10, 2014
@ankur0101
Copy link

I have latest version but still facing this bug. I am unable to use it for ui.select. For ui.bootstrap it worked.

.config(['$ocLazyLoadProvider', function ($ocLazyLoadProvider) {
        $ocLazyLoadProvider.config({
            loadedModules: ['ui.bootstrap', 'ngSanitize', 'ui.select'],
            debug: true
        });
    }])

@ocombe
Copy link
Owner

ocombe commented Nov 26, 2014

Any chance to have a plunkr ?

@hippich
Copy link

hippich commented Dec 5, 2014

Was stuck with this issue as well. No plunkr as app is huge, but change proposed there - edigitalresearch@c9a1a2c seems to fix it

hippich added a commit to hippich/ocLazyLoad that referenced this issue Dec 5, 2014
hippich added a commit to hippich/ocLazyLoad that referenced this issue Dec 5, 2014
@ankur0101
Copy link

@hippich , thanks for your fix. BTW I forgot to mention that I am using Angular 1.2.26

@hippich
Copy link

hippich commented Dec 8, 2014

@ankur0101, so did it work for you? because I am using angular 1.3.x and may be it is angular 1.3.x only fix.

@ocombe
Copy link
Owner

ocombe commented Dec 8, 2014

Your fix is for both, but the problem is that we should allow runblocks & invokeQueue to be called under certain circumstances even if the module isn't new. That's why I need to reproduce the problem and to fix the real issue. I can't merge this fix...

@ocombe ocombe closed this as completed in 01936cd Dec 30, 2014
@ocombe
Copy link
Owner

ocombe commented Dec 30, 2014

Check 0.5.2 I think that it should fix your bug :)

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

No branches or pull requests

5 participants