Skip to content

NgUpgrade bootstrap not resolving Ng1 rootScopePrototype when ng1 bootstrap is deferred #6547

Closed

Description

@danoph

While trying to upgrade an app, I ran into an issue with protractor where ngUpgrade's bootstrap is not waiting for ng1 to completely load if deferred bootstrapping is used (which is what protractor and browser plugins like Batarang do). I am getting this error when running protractor:
Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability\nhttp://errors.angularjs.org/1.4.8/ng/test"

After some digging in UpgradeAdapter, I noticed there is an IF check around the ng2 bootstrap that doesn't run ng'1 rootScope.$apply function. If ng1 bootstrap is deferred, the rootScopePrototype doesn't get resolved before this runs:

Promise.all([this.compileNg2Components(compiler, hostViewFactoryRefMap), ng1compilePromise])
    .then(() => {
      ngZone.run(() => {
        if (rootScopePrototype) {
          rootScopePrototype.$apply = original$applyFn;  // restore original $apply
          while (delayApplyExps.length) {
            rootScope.$apply(delayApplyExps.shift());
          }
          (<any>upgrade)._bootstrapDone(applicationRef, ng1Injector);
          rootScopePrototype = null;
        }
      });
    }, onError);

Activity

  1. added a commit that references this issue on Feb 11, 2016
    3f0b53f
  2. petebacondarwin commented on Dec 21, 2016

    @petebacondarwin
    Contributor

    I believe this was fixed by #7603

  3. angular-automatic-lock-bot commented on Sep 10, 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.

  4. locked and limited conversation to collaborators on Sep 10, 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions