I have a weird problem on an Angular 4 application. My component subscribes on a BehaviorSubject of a Service. On its subscribe ( or map, doesnt change in the end ) I call data.json() which the first time it runs ( coming from the default value of BehaviorSubject, which is an empty array ) it fails as array doesnt have a .json function.
//service.ts
private _errors: BehaviorSubject<any> = new BehaviorSubject([]);
public readonly errors: Observable<any> = this._errors.asObservable();
//component.ts
this.errors.subscribe(
(data) => {
const errorJSON = data.json();
}
);
In some pc's this error doesnt prevent the rest application to run as exprected ( actually, the error isn't even thrown ) . In others this error gets thrown and the rest application fails.
All the pc's have exactly the same environment, running same commands and angular-cli and local angular dependencies. That happens either with ng serve or ng build. After many attempts to locate the root cause of this error, we found out that it has to do something with the build process, as the produced files from the "working pc" can successfully run on the "not working pc", while the opposite ( produced files from the "non working pc" transfered on the "working pc" ) fails.
What could the root of this problem be? Should the default behaviour of this error be to be thrown or not? In any case, has anyone experienced something similar or have anything to propose as to why this happen?