angular / angular

Deliver web apps with confidence 🚀
https://angular.dev
MIT License
94.71k stars 24.68k forks source link

"ng test" : Unhandled promise rejection: Error: Injector has already been destroyed. #55632

Closed puranjayjain closed 2 weeks ago

puranjayjain commented 2 weeks ago

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

When running "ng test --code-coverage", keep getting this error "Unhandled promise rejection: Error: Injector has already been destroyed."

over karma dashboard if it keep refreshing, this error goes away and code coverage appears. This same error was happening in this issue

I am using angular 16 and the latest versions of karma and other deps

Snapshot of the package.json

    "karma": "~6.4.3",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.1",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "^2.1.0",
    "karma-spec-reporter": "^0.0.36",

The error is the same as that previous error

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

NG0205: Injector has already been destroyed.
Error: NG0205: Injector has already been destroyed.
    at R3Injector.assertNotDestroyed (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:9396:19)
    at R3Injector.runInContext (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:9268:14)
    at HttpInterceptorHandler.chain (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/common/fesm2022/http.mjs:1624:57)
    at HttpInterceptorHandler.handle (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/common/fesm2022/http.mjs:1683:21)
    at project (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/common/fesm2022/http.mjs:1228:70)
    at doInnerSub (http://localhost:9876/_karma_webpack_/webpack:/node_modules/rxjs/dist/esm/internal/operators/mergeInternals.js:19:19)
    at onNext (http://localhost:9876/_karma_webpack_/webpack:/node_modules/rxjs/dist/esm/internal/operators/mergeInternals.js:14:57)
    at OperatorSubscriber._next (http://localhost:9876/_karma_webpack_/webpack:/node_modules/rxjs/dist/esm/internal/operators/OperatorSubscriber.js:13:21)
    at OperatorSubscriber.next (http://localhost:9876/_karma_webpack_/webpack:/node_modules/rxjs/dist/esm/internal/Subscriber.js:31:18)
    at Observable._subscribe (http://localhost:9876/_karma_webpack_/webpack:/node_modules/rxjs/dist/esm/internal/observable/innerFrom.js:51:24)
    at Observable._trySubscribe (http://localhost:9876/_karma_webpack_/webpack:/node_modules/rxjs/dist/esm/internal/Observable.js:37:25)
    at cb (http://localhost:9876/_karma_webpack_/webpack:/node_modules/rxjs/dist/esm/internal/Observable.js:31:30)
    at errorContext (http://localhost:9876/_karma_webpack_/webpack:/node_modules/rxjs/dist/esm/internal/util/errorContext.js:19:9)
    at Observable.subscribe (http://localhost:9876/_karma_webpack_/webpack:/node_modules/rxjs/dist/esm/internal/Observable.js:22:21)
    at mergeInternals (http://localhost:9876/_karma_webpack_/webpack:/node_modules/rxjs/dist/esm/internal/operators/mergeInternals.js:50:12)

Please provide the environment you discovered this bug in (run ng version)

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 16.2.14
Node: 20.8.0 (Unsupported)
Package Manager: yarn 3.8.1
OS: darwin arm64

Angular: 16.2.12
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1602.14
@angular-devkit/build-angular   16.2.14
@angular-devkit/core            16.2.14
@angular-devkit/schematics      16.2.14
@angular/cdk                    16.2.14
@angular/cli                    16.2.14
@angular/material               16.2.14
@schematics/angular             16.2.14
rxjs                            7.8.1
typescript                      5.1.6
zone.js                         0.14.5

Anything else?

No response

JeanMeche commented 2 weeks ago

Hello, we reviewed this issue and determined that it doesn't fall into the bug report or feature request category. This issue tracker is not suitable for support requests, please repost your issue on StackOverflow using tag angular.

If you are wondering why we don't resolve support issues via the issue tracker, please check out this explanation.