Random "Uncaught runtime errors" messages after upgrading to latest CRA and Node 18

huangapple go评论63阅读模式
英文:

Random "Uncaught runtime errors" messages after upgrading to latest CRA and Node 18

问题

Our DevOps team informed us that they will be upgrading all servers to Node 18. But our app was working properly only with Node 16. So I upgraded CRA to latest version and at first it seems fine. But then random "Uncaught runtime errors" overlay messages begin popping up in development mode. They are completely random, when I click a link sometimes it shows up, the next time it doesn't show up. I can't find the source of the problem according to error messages. Message are always like this:

Uncaught runtime errors:
×
ERROR
Cancel
    at handleError (http://localhost:3000/static/js/bundle.js:614149:58)
    at http://localhost:3000/static/js/bundle.js:614172:7

When I look at console, it is like this:

Uncaught (in promise) 
Cancel {message: undefined}
message: undefined
[[Prototype]]: Object

When I look at the specified rows at bundle.js, they are like this:

bundle.js:614149:58

var handleError is defined as follows:
     var errorObject = error instanceof Error ? error : new Error(error || fallbackMessage);
      var shouldDisplay = typeof options.catchRuntimeError === "function" ? options.catchRuntimeError(errorObject) : true;
      if (shouldDisplay) {
        overlayService.send({
          type: "RUNTIME_ERROR",
          messages: [{
            message: errorObject.message,
            stack: (0,_overlay_runtime_error_js__WEBPACK_IMPORTED_MODULE_1__.parseErrorToStacks)(errorObject)
          }]
        });

bundle.js:614172:7

(0,_overlay_runtime_error_js__WEBPACK_IMPORTED_MODULE_1__.listenToUnhandledRejection)(function (promiseRejectionEvent) {
   var reason = promiseRejectionEvent.reason;
      handleError(reason, "Unknown promise rejection reason");
    });
英文:

Our DevOps team informed us that they will be upgrading all servers to Node 18. But our app was working properly only with Node 16. So I upgraded CRA to latest version and at first it seems fine. But then random "Uncaught runtime errors" overlay messages begin popping up in development mode. They are completely random, when I click a link sometimes it shows up, the next time it doesn't show up. I can't find the source of the problem according to error messages. Message are always like this:

Uncaught runtime errors:
×
ERROR
Cancel
    at handleError (http://localhost:3000/static/js/bundle.js:614149:58)
    at http://localhost:3000/static/js/bundle.js:614172:7

When I look at console, it is like this:

Uncaught (in promise) 
Cancel {message: undefined}
message: undefined
[[Prototype]]: Object

When I look at the specified rows at bundle.js, they are like this:

bundle.js:614149:58

var handleError = function handleError(error, fallbackMessage) {
     **var errorObject = error instanceof Error ? error : new Error(error || fallbackMessage);**
      var shouldDisplay = typeof options.catchRuntimeError === "function" ? options.catchRuntimeError(errorObject) : true;
      if (shouldDisplay) {
        overlayService.send({
          type: "RUNTIME_ERROR",
          messages: [{
            message: errorObject.message,
            stack: (0,_overlay_runtime_error_js__WEBPACK_IMPORTED_MODULE_1__.parseErrorToStacks)(errorObject)
          }]
        });

bundle.js:614172:7

(0,_overlay_runtime_error_js__WEBPACK_IMPORTED_MODULE_1__.listenToUnhandledRejection)(function (promiseRejectionEvent) {
   **var reason = promiseRejectionEvent.reason;**
      handleError(reason, "Unknown promise rejection reason");
    });

答案1

得分: 1

最终我找到了问题的根源。webpack-dev-server的最新版本新增了一个名为“Overlay displays unhandled promise rejection”的功能描述。这正是导致问题的原因,降级到以前的版本解决了这个问题。

英文:

Finally I found the source of the problem. Latest version of webpack-dev-server has a new feature described as "Overlay displays unhandled promise rejection". This was causing the problem, downgrading to previous version solved it.

huangapple
  • 本文由 发表于 2023年5月17日 14:55:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76269286.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定