create-react-app 开发服务器在webpackHotDevClient.js中出现断开连接错误,

xmjla07d  于 22天前  发布在  React
关注(0)|答案(4)|浏览(19)

我正在使用CRA创建的应用中遇到了这个错误信息。

The development server has disconnected.
Refresh the page if necessary. webpackHotDevClient.js:76
[HMR] Waiting for update signal from WDS..

这是我项目中的依赖项:

"dependencies": {
    "@testing-library/jest-dom": "^5.16.1",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-router-dom": "^6.0.2",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.1.2"
  },

wkyowqbh

wkyowqbh1#

可能你启动服务器的终端已经终止或退出了进程。

jogvjijk

jogvjijk2#

@haneenmahd 不,它不是。错误指向文件 /static/js/vendors~main.chunk.js

var connection = new WebSocket(url.format({
  protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',
  hostname: undefined || window.location.hostname,
  port: undefined || window.location.port,
  // Hardcoded in WebpackDevServer
  pathname: undefined || '/sockjs-node',
  slashes: true
})); // Unlike WebpackDevServer client, we won't try to reconnect
// to avoid spamming the console. Disconnect usually happens
// when developer stops the server.

connection.onclose = function () {
  if (typeof console !== 'undefined' && typeof console.info === 'function') {
    console.info('The development server has disconnected.\nRefresh the page if necessary.');
  }
}; // Remember some state related to hot module replacement.
9gm1akwq

9gm1akwq3#

我也遇到了这个问题,已经搜索了几个小时试图弄清楚。这是我的第一个CRA项目,我正在尝试学习,所以完全有可能我搞砸了什么东西。但我肯定想解决它。我对开发服务器的角色仍然不清楚;然而,我注意到我在连接自动超时之前(大约60秒)所做的更改(到代码)在浏览器中更新,直到超时;之后,我必须刷新浏览器。我想弄清楚如何保持这个连接活跃,这样我就不必在我开发的时候一直刷新了。

我的项目位于Nginx反向代理后面。因此,我尝试了8203中关于proxy_send_timeout和proxy_read_timeout的解决方案,但我没有注意到任何效果。为了行为比较,我将我的应用程序与Unifi控制器进行了比较(它只是我能想到的第一个我知道使用WS的Web应用程序),我注意到工作应用程序似乎在超时之前触发连接刷新,而我的应用程序只是超时并断开连接。

0aydgbwb

0aydgbwb4#

@dever23b 没有真正的选择。
参见 #3210
这个问题解释了你大部分的问题。

相关问题