Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular project compiling / refreshing page on his own

Tags:

angular

After a few minutes after I run angular project by running ng serve angular cli compiling the project and refreshing page multiple times by itself although there are no updates / changes in code

 Date: 2019-07-18T08:23:29.120Z - Hash: 05d5fccc26f4af73d3 - Time: 502ms
 14 unchanged chunks
 i 「wdm」: Compiled successfully.
 i 「wdm」: Compiling...

 Date: 2019-07-18T08:28:50.519Z - Hash: 05d5fccc26f4af73d3 - Time: 869ms
 14 unchanged chunks
 i 「wdm」: Compiled successfully.
 i 「wdm」: Compiling...

 Date: 2019-07-18T08:47:26.476Z - Hash: 05d5fccc26f4af73d3 - Time: 710ms
 14 unchanged chunks
 i 「wdm」: Compiled successfully.

There are no errors in angular cli, just showing multiple compile logs

like image 938
Massaget Avatar asked Jan 27 '26 21:01

Massaget


1 Answers

In my case, I was having an unhandled http request. Once I added an exception, the problem stopped happening.

  private handleError(error: HttpErrorResponse) {
    if (error.error instanceof ErrorEvent) {
      // A client-side or network error occurred. Handle it accordingly.
      console.error('An error occurred:', error.error.message);
    } else {
      // The backend returned an unsuccessful response code.
      // The response body may contain clues as to what went wrong.
      console.error(
        `Backend returned code ${error.status}, ` +
        `body was: ${error.error}`);
    }
    // Return an observable with a user-facing error message.
    return throwError(
      'Something bad happened; please try again later.');
  }

  // settings
  getSettings(): Observable<Settings> {
    return this.http.get<Settings>(`${this.localUrl}getSettings`)
      .pipe(map(response => response))
      .pipe(catchError(this.handleError))
  }
like image 112
Alejandromusic Avatar answered Jan 30 '26 12:01

Alejandromusic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!