You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular13生产环境突发Uncaught TypeError: Illegal invocation问题求助

Angular13生产环境「Uncaught TypeError: Illegal invocation」问题排查求助

问题背景

  • 基于Angular13开发的项目,自2024年2月24日起生产环境突然出现「Uncaught TypeError: Illegal invocation」错误,近期无代码部署变更,此前运行稳定
  • 问题仅部分用户触发:印度地区用户使用正常,切换至美国VPN网络则触发错误
  • 用户操作表现:登录页面输入凭证点击登录后,控制台弹出该错误并阻止进入系统;调试发现错误进入Http拦截器的else (!error.status)分支,网络面板未捕获到失败前的API请求
  • 部署环境:EC2实例,核心诉求为保障用户正常登录

相关代码与报错信息

Http拦截器代码

intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
    if (!req || !req.url || (/^http/.test(req.url) && !(environment.serverUrl && req.url.startsWith(environment.serverUrl)))) {
      return next.handle(req);
    }

    const authToken = this.storageService.get(AppConstants.authenticationToken);
    const encryptUserId = this.storageService.get(AppConstants.encryptUserId);
    let authRequest;
    if (authToken) {
      authRequest = req.clone({
        headers: req.headers.set('Authorization', 'Bearer ' + authToken)
      });
    } else if (encryptUserId) {
      authRequest = req.clone({
        headers: req.headers.set('API', encryptUserId)
      });
    } else {
      authRequest = req.clone();
    }
    authRequest = authRequest.clone({
      url: environment.serverUrl + authRequest.url
    });
    return next.handle(authRequest).pipe(
      tap(
        (event: HttpEvent<string>) => {
          this.requestSuccess(event);
        },
        error => {
          return throwError(error);
        }
      ),
      catchError(error => {
        if (error.error instanceof Error) {
          // A client-side or network error occurred. Handle it accordingly.
        } else {
          if (!error.status) { // here it goes when it breaks
            this.alertService.showErrorToast(ErrorMessages.serverNotAvailable);
            localStorage.clear();
            this.router.navigateByUrl('/auth/login');
          } else if (error.status === 405) {
            this.alertService.showErrorToast(error.message);
          } else if (error.status === 401) {
            this.alertService.showErrorToast(error.Message);
            localStorage.clear();
            this.router.navigateByUrl('/auth/login');
          } else if (error.status === 400 || error.status === 404 || error.status === 500) {
            if (error.status === 500 && error.url.search('downloadPdfReport') > 1) {
              this.alertService.showErrorToast(ErrorMessages.downloadErrorMessage);
            }
          } else if (error.status === 400 && (error.url.search('downloadPdfReport') > 1 || error.url.search('downloadPptReport') > 1)) {
            this.alertService.showErrorToast(ErrorMessages.downloadErrorMessage);
          }
          // reset password messge
          else if (error.status === 400) {
            if (error.email) {
              this.alertService.showErrorToast(error.email[0]);
            } else {
              this.alertService.showErrorToast(error.message);
            }
          }
        }
        return throwError(error);
      })
    );
  }

报错栈信息

main.8558c5021b62b982.js?__cpo=aHR0cHM6Ly93d3cucWVzb2xhcnRvb2xzLmNvbQ:1 Google Maps JavaScript API has been loaded directly without loading=async. This can result in suboptimal performance. For best-practice loading patterns please see https://goo.gle/js-api-loading
(anonymous) @ main.8558c5021b62b982.js?__cpo=aHR0cHM6Ly93d3cucWVzb2xhcnRvb2xzLmNvbQ:1
fca @ js?key=AIzaSyAObJC1CaYEzUMUBnRUd8yLJlwNF78W5Uo&callback=Function.prototype:218
google.maps.Load @ js?key=AIzaSyAObJC1CaYEzUMUBnRUd8yLJlwNF78W5Uo&callback=Function.prototype:14
(anonymous) @ js?key=AIzaSyAObJC1CaYEzUMUBnRUd8yLJlwNF78W5Uo&callback=Function.prototype:389
(anonymous) @ js?key=AIzaSyAObJC1CaYEzUMUBnRUd8yLJlwNF78W5Uo&callback=Function.prototype:389
polyfills.dbac6c637fb0a656.js?__cpo=aHR0cHM6Ly93d3cucWVzb2xhcnRvb2xzLmNvbQ:1 Uncaught TypeError: Illegal invocation
    at n.onreadystatechange [as __zone_symbol__ON_PROPERTYreadystatechange] (polyfill.min.js?features=default:81:311)
    at XMLHttpRequest.We (polyfills.dbac6c637fb0a656.js?__cpo=aHR0cHM6Ly93d3cucWVzb2xhcnRvb2xzLmNvbQ:1:11618)
    at XMLHttpRequest.E (main.8558c5021b62b982.js?__cpo=aHR0cHM6Ly93d3cucWVzb2xhcnRvb2xzLmNvbQ:1:406592)
    at v.invokeTask (polyfills.dbac6c637fb0a656.js?__cpo=aHR0cHM6Ly93d3cucWVzb2xhcnRvb2xzLmNvbQ:1:7278)
    at M.runTask (polyfills.dbac6c637fb0a656.js?__cpo=aHR0cHM6Ly93d3cucWVzb2xhcnRvb2xzLmNvbQ:1:2673)
    at m.invokeTask [as invoke] (polyfills.dbac6c637fb0a656.js?__cpo=aHR0cHM6Ly93d3cucWVzb2xhcnRvb2xzLmNvbQ:1:8329)
    at Z (polyfills.dbac6c637fb0a656.js?__cpo=aHR0cHM6Ly93d3cucWVzb2xhcnRvb2xzLmNvbQ:1:20944)
    at N (polyfills.dbac6c637fb0a656.js?__cpo=aHR0cHM6Ly93d3cucWVzb2xhcnRvb2xzLmNvbQ:1:21237)
    at XMLHttpRequest.B (polyfills.dbac6c637fb0a656.js?__cpo=aHR0cHM6Ly93d3cucWVzb2xhcnRvb2xzLmNvbQ:1:21503)
    at eval (eval at <anonymous> (__cpa.cp.js?__cpo=1&dummy=0b012c75eee6abe70077daa1cbdec021:8:2), <anonymous>:3:98987)
    at XMLHttpRequest.eval (eval at <anonymous> (__cpa.cp.js?__cpo=1&dummy=0b012c75eee6abe70077daa1cbdec021:8:2), <anonymous>:3:106097)
    at XMLHttpRequest._0x52390f [as __zone_symbol__open] (eval at <anonymous> (__cpa.cp.js?__cpo=1&dummy=0b012c75eee6abe70077daa1cbdec021:8:2), <anonymous>:3:98905)
    at polyfills.dbac6c637fb0a656.js?__cpo=aHR0cHM6Ly93d3cucWVzb2xhcnRvb2xzLmNvbQ:1:32647
    at o.<computed> [as open] (polyfills.dbac6c637fb0a656.js?__cpo=aHR0cHM6Ly93d3cucWVzb2xhcnRvb2xzLmNvbQ:1:13594)
    at O.open (scripts.533134a388cfabad.js:1:4357)
    at s.a [as open] (polyfill.min.js?features=default:81:999)
    at _.G.send (js?key=AIzaSyAObJC1CaYEzUMUBnRUd8yLJlwNF78W5Uo&callback=Function.prototype:239:373)
    at dca (js?key=AIzaSyAObJC1CaYEzUMUBnRUd8yLJlwNF78W5Uo&callback=Function.prototype:225:305)
    at fca (js?key=AIzaSyAObJC1CaYEzUMUBnRUd8yLJlwNF78W5Uo&callback=Function.prototype:219:253)
    at google.maps.Load (js?key=AIzaSyAObJC1CaYEzUMUBnRUd8yLJlwNF78W5Uo&callback=Function.prototype:14:5)
    at js?key=AIzaSyAObJC1CaYEzUMUBnRUd8yLJlwNF78W5Uo&callback=Function.prototype:389:634
    at js?key=AIzaSyAObJC1CaYEzUMUBnRUd8yLJlwNF78W5Uo&callback=Function.prototype:389:647

求助

请问是否有人遇到过类似问题?恳请提供解决方案,如需更多信息可随时补充。

内容的提问来源于stack exchange,提问作者prashant Sfl

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 02:17:03