Home > Software engineering >  Browser DevTools won't let me set breakpoints on certain lines even after I cleaned cache and r
Browser DevTools won't let me set breakpoints on certain lines even after I cleaned cache and r

Time:02-23

I have an angular project:

  • angular version is 9.x
  • Typescript version is 3.8.x

I can set breakpoint in every lines when I run in ng serve

But I can't set breakpoint in some lines when I run in ng build

This is is my compile options:

              "optimization": true,
              "outputHashing": "none",
              "sourceMap": true,
              "extractCss": false,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,

This is my related code:

    static httpHandle(error: HttpErrorResponse): Observable<HttpEvent<any>>{
            let errorMessage = '';
            if (error.error instanceof ErrorEvent) {
                // client-side error
                errorMessage = `Error: ${error.error.message}`;
            } else {
                // server-side error
                errorMessage = `Error Status: ${error.status} -- Message: ${error.message}`;
                if (error.status === 404){
                    errorMessage = "API is not found, Please contact Admin";
                }else if (error.status === 400){
                    errorMessage = error.error;
                }else if (error.status === 403){
                    errorMessage = `You don't have permission to do this`;
                }else if (error.status === 401){
                    errorMessage = `Session timeout, Please relogin`;
                }else{
                    errorMessage = `API Error: ${error.status} ${error.statusText}`;
                }
            }
            console.log(errorMessage);
            return throwError(errorMessage);
    }

In compiled code, only 3 lines can set breakpoint, In ng serve, all non-grey line can set breakpoint

I saw somebody mentioned to reopen devTools and clean cache Chrome DevTools won't let me set breakpoints on certain lines I tried , still has the issue.

I also tried both Chrome and Edge, they have exact the same issue.

CodePudding user response:

I can debug on all code lines after I changed optimization to false, but the generated file 8 times bigger

  • Related