Skip to content

Using ngHttp.HTTP_BINDINGS in SFX build causes InvalidBindingError in alpha.35 #3898

Closed

Description

@alfonso-presa

When using ngHttp.HTTP_BINDINGS in angular's 2.0.0_alpha.35 sfx.dev build it's throwing the following error:

InvalidBindingError {message: "Invalid binding - only instances of Binding and Type are allowed, got: [object Object]", _originalException: undefined, _originalStack: undefined, _context: undefined, stack: "Error↵    at InvalidBindingError.BaseException (ht….org/2.0.0-alpha.35/angular2.sfx.dev.js:20107:38)"}

Error
    at InvalidBindingError.BaseException (https://code.angularjs.org/2.0.0-alpha.35/angular2.sfx.dev.js:11539:25)
    at new InvalidBindingError (https://code.angularjs.org/2.0.0-alpha.35/angular2.sfx.dev.js:12886:65)
    at _resolveBindings (https://code.angularjs.org/2.0.0-alpha.35/angular2.sfx.dev.js:32901:15)
    at _resolveBindings (https://code.angularjs.org/2.0.0-alpha.35/angular2.sfx.dev.js:32897:20)
    at Function.System.register.execute.Injector.resolve (https://code.angularjs.org/2.0.0-alpha.35/angular2.sfx.dev.js:33554:36)
    at Injector.System.register.execute.Injector.resolveAndCreateChild (https://code.angularjs.org/2.0.0-alpha.35/angular2.sfx.dev.js:33325:45)
    at _createAppInjector (https://code.angularjs.org/2.0.0-alpha.35/angular2.sfx.dev.js:36509:26)
    at https://code.angularjs.org/2.0.0-alpha.35/angular2.sfx.dev.js:36475:27
    at Zone.run (https://code.angularjs.org/2.0.0-alpha.35/angular2.sfx.dev.js:136:17)
    at Zone.System.register.execute.NgZone._createInnerZone.zone.fork.fork.$run [as run] (https://code.angularjs.org/2.0.0-alpha.35/angular2.sfx.dev.js:20107:38)

Here you have a plunkr to reproduce the issue:
http://plnkr.co/edit/XIW0EgIZvs3dtNcYN1dJ?p=preview

If you change ngHttp.HTTP_BINDINGS for the following code, then everything works:

[
   ng.bind(ngHttp.ConnectionBackend).toClass(ngHttp.XHRBackend), 
   ngHttp.BrowserXhr, 
   ng.bind(ngHttp.RequestOptions).toClass(ngHttp.BaseRequestOptions),
   ng.bind(ngHttp.ResponseOptions).toClass(ngHttp.BaseResponseOptions),
   ngHttp.Http
]

Looks like ngHttp module is using a somehow incompatible binding mechanism to generate HTTP_BINDINGS.

If I'm making something wrong any advice is welcome. Also if you think I can give you a hand to resolve this give me some tips and I'll PR with a solution.

Thank you!

Activity

  1. alfonso-presa commented on Aug 30, 2015

    @alfonso-presa
    ContributorAuthor

    Looks like the BindingBuilder class is duplicated in both bundles. Changing line 11020 in http.sfx.dev.js for the following also did the trick:

    BindingBuilder = ng.BindingBuilder || (function() {

    I guess it's because both bundles are built with angular2/src/di/binding.ts embedded and they are conflicting one with the other.

  2. alfonso-presa commented on Aug 30, 2015

    @alfonso-presa
    ContributorAuthor

    @jeffbcross. Looking at this issue more in detail I have come to this other: #2680

    Looks like the http sfx build was done here:
    5a40501#diff-b9e12334e9eafd8341a6107dd98510c9R1017

    And it seems to be undone here:
    8ed22ce#diff-b9e12334e9eafd8341a6107dd98510c9L1118

    Alpha 35 was released in between so it does have the sfx package for http... wich is causing the problem reported in this issue.

    Seen that it has been undone... ¿should I close this issue? Or is http.sfx.dev.js going to come back again in the near future :-).

    Thanks!

    edit: It looks like the cause for this other issue too: #3890

  3. 0x-r4bbit commented on Aug 31, 2015

    @0x-r4bbit
    Contributor

    @alfonso-presa oh wow, thank you for your research on this. I vote for keeping this open once a fix landed in alpha.36+

  4. alfonso-presa commented on Aug 31, 2015

    @alfonso-presa
    ContributorAuthor

    Thank for you response Pascal!
    I'll keep it open then.

  5. jeffbcross commented on Aug 31, 2015

    @jeffbcross
    Contributor

    Hey @alfonso-presa thanks for opening the issue, and sorry for the trouble. I didn't thoroughly test the http sfx bundle when I added it. The SFX http bundle will not exist in future releases, and since this has already been fixed in master, I will go ahead and close this.

  6. alfonso-presa commented on Aug 31, 2015

    @alfonso-presa
    ContributorAuthor

    @jeffbcross, no problem at all :-).

    Problems apart, I really liked the thinking behind the two separate bundles. I though it might be some strategy thing and that it would be extended to some other modules like the router for example. I wish you could give this separation of modules another chance latter on... but first things first of course :-)

    BTW, you might also want to close #3890 as I'm quite sure it's also caused by the two separate bundles.

    Thanks!

  7. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  8. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions