Anuglar-cli > 1.5 - hanging/killing/stressing browser process (chrome, firefox, edge...)
OS?
Windows 10
Versions.
angular-cli: 1.0.0-beta.24 node v6.9.2
Repro steps.
Was using angular cli beta 15 (all good), decide to upgrade to beta 24, got some errors here and there (mainly template reference/paths, type fixing on code) When doing AOT issue with angularfire2 crept out (can't resolve all parameters for FirebaseSdkAuthBackend), did the following to take care of that particular error https://github.com/angular/angularfire2/issues/728
I have installed different cli versions (some did not event work for to get to the point to do a build), the ones that worked for building, and serving the app cause the browser process to spike and hang, I can't even open the dev console to see messages
The browser processes comsume about 30% of CPU and keep doing that until I kill the process
The log given by the failure.
NONE
Mention any other details that might be useful.
FILES before the change of angulcar CLI 15
ANGULAR CLI
{
"project": {
"version": "1.0.0-beta.15",
"name": " "
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": "assets",
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"styles.css"
],
"scripts": [
],
"environments": {
"source": "environments/environment.ts",
"prod": "environments/environment.prod.ts",
"dev": "environments/environment.dev.ts"
}
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"prefixInterfaces": false,
"lazyRoutePrefix": "+"
}
}
-----------------------------------------------------------------------
PACKAGE.JSON
{
"name": "",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/router": "3.2.1",
"angularfire2": "^2.0.0-beta.6",
"core-js": "^2.4.1",
"fullcalendar": "^3.0.0",
"install": "^0.8.1",
"jquery": "^2.2.4",
"jquery-migrate": "^1.4.1",
"jquery.qrcode": "^1.0.3",
"moment": "^2.15.0",
"npm": "^3.10.8",
"primeng": "1.0.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"underscore": "^1.8.3",
"zone.js": "^0.6.23"
},
"devDependencies": {
"@types/jasmine": "^2.2.30",
"@types/underscore": "^1.7.36",
"angular-cli": "1.0.0-beta.15",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.5",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.2"
}
}
-----------------------------------------------------------------------
TSCONFIG
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es6",
"dom"
],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
],
"types": []
}
}
FILES after the change of angulcar CLI 15 Currently at CLI 24
**ANGULAR CLI**
{
"project": {
"version": "1.0.0-beta.24",
"name": " "
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets"
],
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"styles.css"
],
"scripts": [
],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.dev.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"prefixInterfaces": false,
"inline": {
"style": false,
"template": false
},
"spec": {
"class": false,
"component": true,
"directive": true,
"module": false,
"pipe": true,
"service": true
}
}
}
-----------------------------------------------------------------------
PACKAGE JSON
{
"name": " ",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "^2.3.1",
"@angular/compiler": "^2.3.1",
"@angular/core": "^2.3.1",
"@angular/forms": "^2.3.1",
"@angular/http": "^2.3.1",
"@angular/platform-browser": "^2.3.1",
"@angular/platform-browser-dynamic": "^2.3.1",
"@angular/router": "^3.3.1",
"angularfire2": "^2.0.0-beta.7-pre",
"core-js": "^2.4.1",
"fullcalendar": "^3.0.0",
"jquery": "^2.2.4",
"jquery-migrate": "^1.4.1",
"jquery.qrcode": "^1.0.3",
"moment": "^2.13.0",
"primeng": "1.0.0",
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"underscore": "^1.7.36",
"zone.js": "^0.7.2"
},
"devDependencies": {
"@angular/compiler-cli": "^2.3.1",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"@types/moment": "^2.13.0",
"@types/underscore": "^1.7.36",
"angular-cli": "1.0.0-beta.24",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "~4.0.13",
"ts-node": "1.2.1",
"tslint": "^4.0.2",
"typescript": "~2.0.3"
}
}
-----------------------------------------------------------------------
TSCONFIG
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
]
},
"files": [
"main"
]
}
When doing any type of build doing AOT, no error message appear, I just only get quite a few warnings like:
WARNING in ./~/angularFire2/interfaces.js There are multiple modules with names that only differ in casing. This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
WARNING in ./src/app/appcore/viewClasses/components/eventRegistrationInfo.component.ts There are multiple modules with names that only differ in casing. This can lead to unexpected behavior when compiling on a filesystem with other case-semantic. Use equal casing. Compare these module identifiers:
When I was using beta 15 same warning message came up, but my app was able to load/work
THANKS : D
upgrade angularfire2 to 2.0.0-beta.7.1-pre should solve the problem
@sarunint thanks for commenting, I went ahead updated angularfire2 to 2 beta 7.1 pre and things got a bit worse
Left it running for a while and it seems that memory is leaking pretty bad... @davideast any pointers ?
I'll make a new project and start adding my code in stages to see if I'm able to get it to work on the newest angular cli
Well well well well well wellllllllllllllllll..... I've created a brand new spaking project with angular cli beta 24, and started to migrate mi old beta 15 app, adding npm packages 1 by 1, serving the app I can say that as of right now, angularfire2 is NOT the problem....
I hope as I finish migrating my app, I can detect what causes the browser to spike and go bananas...
Any one out there, has had issues with angular2, angular cli or webpack that causes this browser behavior...?
Keep it real dudes
FOUND THE BUG !! :' ( ........... : -)
As the migration of my app to a new project started, chunks of it were being carefully added and tested... when I got to the routing and route guards chunk of my application I started to notice my app behaving as explained above.
infinite redirect loop
I sure don't know what changed on the internals of angular cli beta 15 to 24, or from angular 2.2.1 to 2.3.1 (perhas also the router lib), but something is not watching for redirection loops gone wild.
I guess the browser dont have a way of knowing the angular 2 app is looping like crazy and cant error out the page, like when we are doing plain good old HTTP calls and we get fancy error messages like this one:
“Error 310 (net::ERR_TOO_MANY_REDIRECTS): there were too many redirects”.
Glad you were able to find the bug, closing.
I had the same issue and just as a reference about the solution as 'routing' and 'looping' was the right hint for me to figure it out.
I had to remove the else statement which explicitly redirected to the route. This is not necessary anymore and causes the router to loop infinitely.
AuthGuard.ts
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private auth: AngularFireAuth, private router: Router) {
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
return Observable.from(this.auth)
.take(1)
.map(state => !!state)
.do(authenticated => {
if (!authenticated) this.router.navigate(['/login']);
})
}
}
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.