webpack-dev-server icon indicating copy to clipboard operation
webpack-dev-server copied to clipboard

[WDS] disconnected! constantly appear on windows 8

Open sdhhqb opened this issue 10 years ago • 26 comments

One of our team member's system is win8, when he run webpack-dev-server everything seems worked. But every few seconds a [WDS] disconnected! error shows in console and page then refresh.

In the meantime, this issue don't appear on win7.

I had tried ways mentioned in #326, still can't solve the problem.

Here is our webpack.config.js

var webpack = require("webpack");
var path = require("path");
var HtmlWebpackPlugin = require('html-webpack-plugin');

var config = {
    entry: {
        "vendor1": ["react", "react-dom", "react-router", "react-router-redux", "react-redux", "redux"],
        "vendor2": ["crypto-js", "fastclick"],
        "app": "./js/index.js"
    },

    output: {
        path: './build/',
        filename: 'js/[name].js',
        publicPath: '/build/',
        chunkFilename: "js/[id].bundle.js"
    },

    module: {
        loaders: [
            {
                test: /\.js$/, 
                include: [
                    path.resolve(__dirname, "js")
                ],
                exclude: [
                    path.resolve(__dirname, "build"),
                    path.resolve(__dirname, "node_modules")
                ],
                loader: 'babel-loader',
                query: {
                    presets: ['es2015', 'react'],
                    plugins: ['transform-object-assign']
                }
            },

            {
                test: /\.css$/,
                loaders: ["style", "css?-minimize"]
            },

            {
        test: /\.(png|jpg|woff|woff2|eot|ttf|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
        loader: 'url?limit=512&&name=[path][name].[ext]?[hash]'
      }
        ]
    },

    plugins: [
        new webpack.optimize.CommonsChunkPlugin({
            names: ["vendor2","vendor1"],
          minChunks: Infinity
        })
    ],

    resolve: {
        modulesDirectories: [
      'node_modules'
    ]
    }
};
module.exports = config;

sdhhqb avatar Aug 03 '16 05:08 sdhhqb

Turns out the problem is related to chrome version, after update chrome to latest version this issue no longer appear.

sdhhqb avatar Aug 03 '16 10:08 sdhhqb

@sdhhqb, weird. It wouldn't make sense to backport a fix for this I think, so can this be closed?

SpaceK33z avatar Aug 03 '16 14:08 SpaceK33z

Sure, it's not worth to solve it.

sdhhqb avatar Aug 04 '16 07:08 sdhhqb

I have the same issue on Mac with the newest (stable) Chrome and Safari.

{
    "webpack": "2.1.0-beta.20",
    "webpack-dev-server": "2.1.0-beta.0",
}

config:

module.exports = env => {
  return {
    devtool: env.prod ? 'source-map' : 'eval',
    entry: [
      'webpack-dev-server/client?http://localhost:3000/',
      'webpack/hot/only-dev-server',
      './src/index',
    ],
    output: {
      filename: 'bundle.js',
      path: resolve(__dirname, 'build'),
      pathinfo: !env.prod,
    },
    bail: env.prod,
    plugins: [
      new HtmlWebpackPlugin({
        title: 'TravelDesk',
        template: 'template.html',
      }),
    ],
    module: {
      loaders: [{
        test: /\.jsx?$/,
        loaders: ['babel'],
        include: resolve(__dirname, 'src'),
      }],
    },
  }
}

ghost avatar Aug 07 '16 16:08 ghost

I have the same issue with latest chrome on win7

superddr avatar Oct 09 '16 10:10 superddr

@MoeSattler and @superddr, are you using the dev-server via CLI?

Note that in dev-server 2.0 beta, the CLI enables inline mode by default. So if you're manually including the webpack-dev-server/client module, the module is loaded two times. Either use the cli with --no-inline, or remove the module from your entry.

SpaceK33z avatar Oct 09 '16 11:10 SpaceK33z

The same problem with latest Firefox Developer Edition 51.0a2. Works fine on Chrome

Details image

Yerkon avatar Nov 12 '16 15:11 Yerkon

https://bugzilla.mozilla.org/show_bug.cgi?id=712329#c23

Yerkon avatar Nov 12 '16 17:11 Yerkon

I'm also getting this issue in one of my projects. For me, the message is (re-)displayed about every 1.2 seconds, with a page refresh. The page loads the https://localhost:8082/sockjs-node/info?t=xxxxxxxxxxxx and a what appears to the be web socket connection request before immediately refreshing.

The problem occurs in Firefox (v52, x64, Xubuntu 15.10), and not in Chrome (56.0.2924.87 x64). [email protected], [email protected]. Also running latest sass/css/style loaders, extract-text-plugin, babel-loader.

For a weird bit, this same config works fine (in Firefox) when the entrypoint isn't my main project. I have three secondary entry points which are compiled with a config file that imports the main one and changes the entry. (Actually, both the main project and secondary configs work like that -- import the main config and set the entry option). The main project uses a few more packages, but I tested requiring each of those in one of the secondary entries, and that didn't reproduce the issue, so it's not as simple as that.

Is it possible that the project size could be affecting this? My main project compile is much larger, and takes significantly longer to compile.

In my main project, I also tried putting a throw new Error(); before any other code. This didn't seem to stop the problem. I'm wondering if maybe there is a hanging WS handler which is catching something before the refresh is done.

Since I have known bad and good configuration, I'm willing to test any ideas which could lead to the cause and solution for this issue. I'm very regularly in #react.js on freenode for faster communication.

UPDATE

I figured out how to reproduce in the my other config. My main project doesn't run on the / web path, it runs in a (virtual) path. It looks like not running from the root triggers the problem. I'm going to see if I can make a minimal reproduction with this info.

samsch avatar Mar 10 '17 14:03 samsch

Ok, I managed to build a minimal test case.

It's important to have a slow server delaying the page load. I'm guessing the issue is a timeout or a web socket message sent right before the page loads/reloads. I'm also guessing that the reason a test case has been hard to recreate is because it's not normal to intentionally slow things down. I picked up on it because I have a project with a backend which is sluggish (at best) on my local dev machine.

The subdirectory bit in my update to the previous comment doesn't seem to be related at all. I think that was just a coincidence. The problem reproduces fine at the root path.

samsch avatar Mar 10 '17 17:03 samsch

@samsch thanks, I can reproduce this now using Firefox on Mac. Chrome works fine as you said. I don't know yet where this issue is coming from, so help would be welcome.

Some things to know; we use http-proxy-middleware for proxying, there could perhaps be a timeout in there. I checked if it could be caused by the HTTP/2 implementation we're using (which is used when https is enabled), but it was not.

SpaceK33z avatar Mar 10 '17 19:03 SpaceK33z

http-proxy-middleware exposes a proxyTimeout option from the underlying node-http-proxy, however, it defaults to not being enabled, and a grep search in this module and webpack-dev-middleware doesn't reveal it being set anywhere.

samsch avatar Mar 10 '17 19:03 samsch

I'm really just scratching at the surface, since I have no prior familiarity with the webpack-dev-server internals.

In client/socket.js, there is a re-connect which takes 1000-1100ms. Could the problem be that the connection is closed on webpack rebuild, the page starts to refresh (causing a connection close, and the [WDS] Disconnected! message), but the timeout fires before the page fully refreshes. Since webpack-dev-server is otherwise idle, the reconnection succeeds, maybe firing reloadApp() in client/index.js?

If this is the problem, then maybe there needs to be onbeforeunload handler which cancels or blocks the timeout?

samsch avatar Mar 13 '17 15:03 samsch

I'm dealing with the same thing. I noticed that the webpack-dev-server version is different from the one I have listed in my package.json. Any chance that could be part of the problem? EDIT: I'm on windows 10 with the latest version of chrome, version 2.2.1 of webpack @samsch

adamwallace avatar Mar 13 '17 16:03 adamwallace

For the fun of it, I tested using version 2.2.0 (original stable v2 release), and it also fails. I don't know if this applies to the v1 branch of the module or not. @adamwallace what version are you using?

samsch avatar Mar 13 '17 17:03 samsch

Can anyone help test #841?

SpaceK33z avatar Mar 13 '17 20:03 SpaceK33z

still have same issue,

"webpack-dev-server": "^2.4.5",
"webpack": "^2.4.1",
"chromium": "57.0.2987.98",
"OS": "Linux"

zba avatar Apr 27 '17 10:04 zba

I failed to reproduce using these versions in my test case:

webpack-dev-server: "2.4.5",
webpack: "2.4.1",
Google Chrome: "57.0.2987.133",
OS: "Xubuntu 17.04"

@zba Can you get a minimal test-case failing? You can fork from my old one if you want.

samsch avatar Apr 27 '17 13:04 samsch

Hello, My team and I are very new to Angular2 and this WDS Disconnected is pretty bad for all of us. We are on Windows 7. Is there a good solution? Any help will be appreciated. Thank you very much!

ocollins avatar Jul 12 '17 12:07 ocollins

@ocollins Can you reproduce the problem in a test case with latest? This problem should be fixed in >=2.4.5.

samsch avatar Jul 12 '17 15:07 samsch