lgalfaso / angular-dynamic-locale

Module to be able to change the locale at an angularjs application
http://lgalfaso.github.io/angular-dynamic-locale/
MIT License
322 stars 75 forks source link

Error during concurrent karma testing: Failed to execute 'removeChild' on 'Node' #122

Closed daldinger closed 6 years ago

daldinger commented 6 years ago

When executing multiple builds in Jenkins that do karma testing on the same build node this error is randomly produced: [exec] "message": "Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.\nat bower_components/angular-dynamic-locale/dist/tmhDynamicLocale.js:60:14\n\nError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.\n at HTMLScriptElement.script.onload (bower_components/angular-dynamic-locale/dist/tmhDynamicLocale.js:60:14)"

I was also able to reproduce the same random error locally by running karma testing with multiple browsers specified in the karma.conf.js:

browsers: ['ChromeHeadless', 'ChromeHeadless'],

From the bower.json: "angular-dynamic-locale": "0.1.29",

This issue looks related to issue #52 and pull request #72. Also, I locally applied the fix proposed in #72 (which basically adds a check that the script is the child of the body before removing it from the body) and validated that the error no longer happens when testing concurrently.

daldinger commented 6 years ago

I tested this again with the latest release (0.1.36) and confirmed the same error is produced. Adding a similar check that the script is the child of the element before removing it from the element resolved the issue.

          if (script.parentNode === element) {
            element.removeChild(script);
          }
lgalfaso commented 6 years ago

By any chance, are you using requirejs? Are you able to reproduce this with a minimal test case?

On Tue, Jun 12, 2018 at 4:49 PM daldinger notifications@github.com wrote:

I tested this again with the latest release (0.1.36) and confirmed the same error is produced. Adding a similar check that the script is the child of the element before removing it from the element resolved the issue.

      if (script.parentNode === element) {
        element.removeChild(script);
      }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lgalfaso/angular-dynamic-locale/issues/122#issuecomment-396617278, or mute the thread https://github.com/notifications/unsubscribe-auth/AAX44u1YVap0xVurRhuzrxNBsvna4nalks5t79TfgaJpZM4UjE4l .

daldinger commented 6 years ago

I think I tracked it down to some nested test suites/contexts that are doing

     afterEach(function() {
        angular.element(document.body).children().remove();
     });
lgalfaso commented 6 years ago

I’m still torn if this should be fixed at the library. Anyhow, given that this is causing issues, will apply the patch and cut a new version in a few days.

On Wed, Jun 13, 2018 at 4:19 PM daldinger notifications@github.com wrote:

I think I tracked it down to some nested test suites/contexts that are doing

 afterEach(function() {
    angular.element(document.body).children().remove();
 });

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/lgalfaso/angular-dynamic-locale/issues/122#issuecomment-396954435, or mute the thread https://github.com/notifications/unsubscribe-auth/AAX44mQl31Uvy7CcUbGfb3u4nZewdZVqks5t8R9jgaJpZM4UjE4l .

lgalfaso commented 6 years ago

Fixed at 0.1.37