英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论