sorry for my bad english :-)
I have a problem I can't actually not really explain.
I use these versions of angular right now: @angular/*: 4.4.6 (Meaning also the @angular/http: 4.4.6 package).
I use RxJS to do http GET request like this one:
import {EventEmitter, Injectable} from '@angular/core';
import {Headers, Http} from '@angular/http';
@Injectable()
export class DataService {
//SOME-CODE
constructor(private _http: Http) {
//SOME-CODE
}
getStatus() {
const headers = new Headers({
'Content-Type': 'application/json'
});
return new Promise((resolve, reject) => {
return this._http.get(
'https://[URL]:[PORT]/[PATH]',
{headers: headers}
).map(
(res) => res.json()
).toPromise()
.then(
(res) => {
if (/*SOME-CONDITION*/) {
return true;
}else{
return false;
}
resolve();
}
).catch(
e => {
//ERROR-HANDLING
return false;
}
);
}
}
}
The request seems to work fine for some browser-sessions but after a while (I cannot tell exactly when) at a certain point when angular app is reloaded/called again after the initial loading the http request gets stuck and browser freezes because of high CPU usage.
My debugging efforts so far:
- It happens at Android, Chrome Browser, Firefox, Safari.
- When using incognito mode in Chrome f.e. it's works, no freezing.
- When using chrome debugging tools and looking into 'network' activities you'll see the 'pending' status on that specific request. When trying to see whats the request header you'll getting a black page in that window where normally informations should be displayed.
- Looking into 'Application' like LocalStorage or cookies there's no hint (f.e. LocalStorage exceeded or cookies being cached).
- When looking into server (simple nodejs webserver) who will provide a response, no request at all comes in.
- I tried to use an another service like "https://jsonplaceholder.typicode.com/" to be sure it's not my server who is not working properly. Same behavior here.
- I tried to use 'Performance' tool from chrome which is really hard to get a snapshot cause CPU freezes fast. Although I made it a few times all I could see was a lot of event firing and zone.js stuff. Nothing special to debug there. Fair to say that I am not an expert to debug internal angular processes.
- Then I tried kicking out every module which I don't need at this dataService. No luck.
- Finally I used a simple XMLHttpRequest() to avoid the angular http module. Nothing changed. Request obviously fired but pending with freeze.
If you're giving up at a certain point and delete Browser cache (f.e. in chrome) and reload the app it's working again.
Does anyone had this kind of issue or was dealing with it? I am going crazy here :-(
Thanks for helping.