Webpack-dev-server: Polling not working in webpack-dev-server

Created on 8 Jun 2015  路  4Comments  路  Source: webpack/webpack-dev-server

I'm trying to set up the webpack-dev-server to watch for changes using the polling mechanism. Polling in general works if I do webpack --watch --watch-polling as mentioned in https://github.com/webpack/webpack/issues/125#issuecomment-109582926, however I cannot get it to work in webpack-dev-server. Following the docs, I'm trying to pass the following option:

watchOptions: {
  poll: true
}

Most helpful comment

@maspwr as written here http://webpack.github.io/docs/webpack-dev-server.html

you must put these lines:

 watchOptions: {
    aggregateTimeout: 300,
    poll: 1000
  },

into WebpackDevServer constructor.

This works fine for me.

All 4 comments

I can confirm that this is an issue with the release (v1.9.0) and commit 8e8f540. Appears to be an issue with socket.io as the exception is on line 23 of socket.io/lib/transport/polling.js
https://github.com/Automattic/engine.io-client/blob/d0e8643d050196ce29d88438d129230817f89c85/lib/transports/polling.js

The webpack output is as follows, and causes an exception (object is not a function):
var xhr = new XMLHttpRequest({ xdomain: false });

Executing the following on the console works as expected:
var xhr = new XMLHttpRequest.XMLHttpRequest({ xdomain: false });

Comparing the result of var XMLHttpRequest = webpack_require(/*! xmlhttprequest */ 19);

Not working:
function XMLHttpRequest()

Working:
function module.exports(opts)

Checking my make-webpack-config.js, I found the problem:

var externals = [{
xmlhttprequest: '{XMLHttpRequest:XMLHttpRequest}'
}];

Removing xmlhttprequest from this array solved my problem. I am pretty sure I put it in there to resolve this issue: https://github.com/webpack/webpack-dev-server/issues/66

@sokra Keep up the great work!

@maspwr as written here http://webpack.github.io/docs/webpack-dev-server.html

you must put these lines:

 watchOptions: {
    aggregateTimeout: 300,
    poll: 1000
  },

into WebpackDevServer constructor.

This works fine for me.

@Andrew8xx8 works like a charme with my vagrant setup. Thank you.

I see that others aren't having this issue. I'll retest when I need to use that functionality again and reopen if I can reproduce the issue. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nikirossi picture nikirossi  路  3Comments

mischkl picture mischkl  路  3Comments

uMaxmaxmaximus picture uMaxmaxmaximus  路  3Comments

antoinerousseau picture antoinerousseau  路  3Comments

hnqlvs picture hnqlvs  路  3Comments