Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get a response from middleware #36

Closed
ingro opened this issue Oct 10, 2015 · 55 comments
Closed

Can't get a response from middleware #36

ingro opened this issue Oct 10, 2015 · 55 comments

Comments

@ingro
Copy link

ingro commented Oct 10, 2015

Hello, I've got this problem trying to use webpack-hot-middlware.

I started a new project from React transform boilerplate but I can't get hot reloading to work.

On the browser I see that the call to http://localhost:3000/__webpack_hmr is made but gets no response, it gets canceled after ~ 20-30 seconds, and then it keep retrying with the same result. The dev tools just shows an empty response.

I'm running node 4.1.2 on Windows 7 x64.

@glenjamin
Copy link
Collaborator

Which browser is this? If you try it in a recent version of chrome then you should see some information about the event stream messages.

Does the logging in the server process or the client show any information or errors?

@ingro
Copy link
Author

ingro commented Oct 10, 2015

Thanks for the reply @glenjamin , I've tried both with Chrome and Firefox.
Looking at the Chrome Network tab I don't see anything, those are the headers of the request:

Accept:text/event-stream
Cache-Control:no-cache
Referer:http://localhost:3000/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2532.0 Safari/537.36

No response is returned (Failed to load response data).

On the server I told the middleware to log with console.log and I can see just those lines:

webpack building...
webpack built db4696f581c672eac1bd in 1603ms

So it seems that the middleware is running but the client can't connect to it. Looking at the middlware code, if I try to add res.end(); after res.write('\n'); the response reach the client, but as the stream is also closing the reload isn't happening.

@glenjamin
Copy link
Collaborator

Can you use cURL to connect to the HMR endpoint? You should see a beating heart emoji 💓 every few seconds.

If not, can you post your full express server setup? It would appear that the middleware isn't getting loaded properly.

@ingro
Copy link
Author

ingro commented Oct 10, 2015

Nope, request time out even with curl.

Express setup has ben cloned from this boilerplate, so should be a pretty basic one.

@glenjamin
Copy link
Collaborator

I've checked on Node v.4.1.2 with the boilerplate before making any changes - it works as expected. I only have OS X available, so can't vouch for windows.

If you haven't made any changes I'd recommend trying another sample project to see if there are any differences, like this one - https://github.com/glenjamin/ultimate-hot-reloading-example, or the example/ folder included in this repo.

If those work then the issue must be with the boilerplate, if not then I'm stumped.

@ingro
Copy link
Author

ingro commented Oct 11, 2015

Tried both, same result.

Guess it could be a problem with my machine, but I don't know where to look to find a solution or what may cause this strange behaviour.

@glenjamin
Copy link
Collaborator

Is your browser connecting directly to the stream? Any kind of proxy in the way? We saw a similar issue with #10

@ingro
Copy link
Author

ingro commented Oct 11, 2015

Not that I'm aware of, also I don't think it's a browser problem since also curl request times out...

@ingro
Copy link
Author

ingro commented Oct 11, 2015

Looking at the server of the example folder of this repo, that's what I see:

::1 - GET /__webpack_hmr HTTP/1.1 200 - - 0.162 ms

But with curl:

curl http://localhost:1616/__webpack_hmr -m 10
curl: (28) Operation timed out after 10015 milliseconds with 0 out of -1 bytes received

@glenjamin
Copy link
Collaborator

Weird, here's what it should look like, the cURL request stays open forever (until manually killed).

> time curl localhost:1616/__webpack_hmr -v
*   Trying ::1...
* Connected to localhost (::1) port 1616 (#0)
> GET /__webpack_hmr HTTP/1.1
> Host: localhost:1616
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Content-Type: text/event-stream;charset=utf-8
< Transfer-Encoding: chunked
< Cache-Control: no-cache, no-transform
< Connection: keep-alive
< Date: Sun, 11 Oct 2015 13:08:43 GMT
<

data: 💓

data: 💓

data: 💓

^C

real    0m36.292s
user    0m0.004s
sys 0m0.006s
> npm start

> [email protected] start /Users/glen/Development/GitHub/webpack-hot-middleware/example
> node server.js

Listening on {"address":"::","family":"IPv6","port":1616}
webpack built 8b53317b98740d543088 in 202ms
::1 - GET /__webpack_hmr HTTP/1.1 200 - - 1.877 ms

The log line on the server side doesn't appear until the incoming request has completed.

It might be that 10 seconds is too short - the heartbeat is set to exactly 10 seconds by default. Try either making cURL wait a bit longer, or reducing the timeout setting on the server.

@ingro
Copy link
Author

ingro commented Oct 11, 2015

Here it is, with 30 seconds timeout:

curl http://localhost:1616/__webpack_hmr -v -m 30
* Adding handle: conn: 0x21735d0
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x21735d0) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 1616 (#0)
*   Trying ::1...
* Connected to localhost (::1) port 1616 (#0)
> GET /__webpack_hmr HTTP/1.1
> User-Agent: curl/7.30.0
> Host: localhost:1616
> Accept: */*
>
* Operation timed out after 30030 milliseconds with 0 out of -1 bytes received
* Closing connection 0
curl: (28) Operation timed out after 30030 milliseconds with 0 out of -1 bytes received

And the server:

λ npm start

> [email protected] start D:\Projects\webpack-hot-middleware\example
> node server.js

Listening on {"address":"::","family":"IPv6","port":1616}
webpack built ed1ca8ae2f35ec4b1186 in 183ms
::1 - GET /__webpack_hmr HTTP/1.1 200 - - 0.506 ms

@glenjamin
Copy link
Collaborator

That makes no sense! It's acting like something is buffering the response, but nothing should be.

Can you try with a slightly older version of nodejs? Can you also include the full output of npm ls in the example folder?

@ingro
Copy link
Author

ingro commented Oct 11, 2015

I can't try it now but I'll do this evening I think. How much older? 4.0 is
fine?

On Sun, 11 Oct 2015 15:24 Glen Mailer [email protected] wrote:

That makes no sense! It's acting like something is buffering the response,
but nothing should be.

Can you try with a slightly older version of nodejs? Can you also include
the full output of npm ls in the example folder?


Reply to this email directly or view it on GitHub
#36 (comment)
.

@glenjamin
Copy link
Collaborator

I'd say try 4.0 and 0.12.

@ingro
Copy link
Author

ingro commented Oct 11, 2015

Tried with Node 4.0 and 0.12.7, no luck.
Also, that's npm ls:

λ npm ls
[email protected] D:\Projects\webpack-hot-middleware\example
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │   └── [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └─┬ [email protected]
│ │   └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │   ├── [email protected]
│ │   ├── [email protected]
│ │   ├── [email protected]
│ │   └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └─┬ [email protected]
│ │ │ │   ├─┬ [email protected]
│ │ │ │   │ ├── [email protected]
│ │ │ │   │ └── [email protected]
│ │ │ │   ├── [email protected]
│ │ │ │   ├─┬ [email protected]
│ │ │ │   │ ├─┬ [email protected]
│ │ │ │   │ │ └─┬ [email protected]
│ │ │ │   │ │   ├── [email protected]
│ │ │ │   │ │   ├── [email protected]
│ │ │ │   │ │   ├── [email protected]
│ │ │ │   │ │   └── [email protected]
│ │ │ │   │ ├── [email protected]
│ │ │ │   │ ├── [email protected]
│ │ │ │   │ └── [email protected]
│ │ │ │   ├── [email protected]
│ │ │ │   ├─┬ [email protected]
│ │ │ │   │ ├─┬ [email protected]
│ │ │ │   │ │ └── [email protected]
│ │ │ │   │ ├── [email protected]
│ │ │ │   │ └── [email protected]
│ │ │ │   ├── [email protected]
│ │ │ │   ├── [email protected]
│ │ │ │   ├── [email protected]
│ │ │ │   ├─┬ [email protected]
│ │ │ │   │ ├─┬ [email protected]
│ │ │ │   │ │ └── [email protected]
│ │ │ │   │ └── [email protected]
│ │ │ │   ├─┬ [email protected]
│ │ │ │   │ ├── [email protected]
│ │ │ │   │ ├── [email protected]
│ │ │ │   │ ├── [email protected]
│ │ │ │   │ └── [email protected]
│ │ │ │   └─┬ [email protected]
│ │ │ │     ├── [email protected]
│ │ │ │     └── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├── [email protected]
│ │ │ └─┬ [email protected]
│ │ │   ├── [email protected]
│ │ │   ├─┬ [email protected]
│ │ │   │ └─┬ [email protected]
│ │ │   │   ├── [email protected]
│ │ │   │   └── [email protected]
│ │ │   └─┬ [email protected]
│ │ │     ├── [email protected]
│ │ │     ├── [email protected]
│ │ │     ├── [email protected]
│ │ │     ├── [email protected]
│ │ │     ├── [email protected]
│ │ │     └── [email protected]
│ │ └── [email protected]
│ └─┬ [email protected]
│   ├── [email protected]
│   └─┬ [email protected]
│     └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ └── [email protected]
└─┬ [email protected]
  ├── [email protected]
  └─┬ [email protected]
    └── [email protected]

@glenjamin
Copy link
Collaborator

Thanks.

I'll see if I can reproduce - something somewhere definitely seems like
it's buffering the response packets.

You could try editing the middleware heartbeat code to produce a much
longer heartbeat packet - something around the 1k mark, and see if that
triggers a flush.

If I can't reproduce on OS X I'm not sure what else I can do - I don't know
how to go about debugging something like this on windows.

On 11 October 2015 at 22:35, Emanuele Ingrosso [email protected]
wrote:

Tried with Node 4.0 and 0.12.7, no luck.
Also, that's npm ls:

λ npm ls
[email protected] D:\Projects\webpack-hot-middleware\example
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └─┬ [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ ├─┬ [email protected]
│ │ │ │ │ │ └─┬ [email protected]
│ │ │ │ │ │ ├── [email protected]
│ │ │ │ │ │ ├── [email protected]
│ │ │ │ │ │ ├── [email protected]
│ │ │ │ │ │ └── [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ ├─┬ [email protected]
│ │ │ │ │ │ └── [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ ├─┬ [email protected]
│ │ │ │ │ │ └── [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ └─┬ [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├── [email protected]
│ │ │ └─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └─┬ [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ └── [email protected]
│ │ │ └─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ └─┬ [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ └── [email protected]
└─┬ [email protected]
├── [email protected]
└─┬ [email protected]
└── [email protected]


Reply to this email directly or view it on GitHub
#36 (comment)
.

@ingro
Copy link
Author

ingro commented Oct 12, 2015

Just a quick update: this morning I tried it on my computer at work, which also runs on Win 7 x64, and hmr runs with no problem, so it's not a general Windows problem...

@spirAde
Copy link

spirAde commented Oct 12, 2015

Same issue.
time curl localhost:3000/__webpack_hmr -v returns the data: 💓, and I see recompiled bundle in terminal, when change a code, but the EventStream tab for __webpack_hmr is empty.

@glenjamin
Copy link
Collaborator

If you're seeing the heartbeat in cURL and the reload event in the console, that's a slightly different issue. Can you report in a separate thread with details of your environment?

@spirAde
Copy link

spirAde commented Oct 13, 2015

Thanks for the reply @glenjamin, I'll write later

@NeXTs
Copy link

NeXTs commented Nov 4, 2015

@spirAde Did you solved your problem?
I'm trying to set up webpack-hot-middleware on VMWare and experience same issue.
localhost:3000/__webpack_hmr returns 💓
but
localhost/__webpack_hmr request fails with "Fail to load response data"

I thought that specifying 3000 port in config's path parameter will be alike workaround, but such syntax is not supported :(

@jgoux
Copy link

jgoux commented Nov 16, 2015

Hello, I have the same issue.
I'm running node.js inside a VM on 0.0.0.0:3000
The content is served on localhost:3000 but the localhost:3000/__webpack_hmr isn't loaded (timeout).
I'm on Chrome version 46.0.2490.86 and Windows 8.1

@glenjamin
Copy link
Collaborator

Can you post your webpack config? Does the curl example above work?

@jgoux
Copy link

jgoux commented Nov 16, 2015

@glenjamin My webpack config is the one from https://github.com/gaearon/react-transform-boilerplate , I just cloned the project and tried to run it.
I can see the heartbeat from both my VM and my host machine with the curl command.
The webpack bundle is also compiled and served on my host.
The calls to http://localhost:3000/__webpack_hmr from the web client all fail. Here is the header sent from Chrome (I also tested with Mozilla Firefox, same issue) :

Request URL:http://localhost:3000/__webpack_hmr
Request Headers
Provisional headers are shown
Accept:text/event-stream
Cache-Control:no-cache
Referer:http://localhost:3000/
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36

@ustccjw
Copy link

ustccjw commented Nov 17, 2015

YES, http://localhost:3000/__webpack_hmr will be pended for about some minutes.

@ustccjw
Copy link

ustccjw commented Nov 19, 2015

My problem was caused by http proxy.

@skolmer
Copy link

skolmer commented Dec 9, 2015

I have the same issue on Win10 x64

@jackgeek
Copy link

I also have same issue on Win10 x64

@skolmer
Copy link

skolmer commented Dec 16, 2015

my config is the one from https://github.com/gaearon/react-transform-boilerplate. no nginx only webpack-dev-server.

@glenjamin
Copy link
Collaborator

This definitely seems to affecting mainly windows, everyone who's managed to resolve this issue has identified some sort of MITM that's buffering or blocking responses.

The steps to debug are:

  • Try a boilerplate that's known to work for others
  • Check that you can see the incoming request in the server logs
  • See if you can connect to the event-source endpoint via cURL and receive data

If you can connect with cURL, there's something messing with the transport when being used in the browser

If you can't connect with cURL, there's something messing with the server's data.

@skolmer
Copy link

skolmer commented Dec 16, 2015

I tried to curl the request but didn't get a response from the middleware.
I will look for other configurations that might affect the event-stream but currently out of ideas where to look. I didn't have this issue with the old react-hot-boilerplate project that was using Webpack Dev Server.
Strange is, a colleague of mine had the exact same project running on his win10 machine.

@pablolmiranda
Copy link

In my case when I removed the express compression middleware the event source started to receive messages again.

@davidhouweling
Copy link

And i am experiencing the issue as well. Windows 10, 64bit. Chrome v47. Similar to others, cloned the template too. Tried on node 4.1.1 and 5.4.1. I can confirm that curl'ing the url does result in the heartbeat. I do agree that something is most likely buffering the response. Connected/disconnected from VPN still results in the same issue. I don't have a proxy set up either.

@davidhouweling
Copy link

To add to my last comment, i did curl with -v... and the first couple of connects it attempted to do resulted in 'port 3000 failed: bad access', but it was trying different IP addresses on my machine. On the 4th attempt it resolved to my machine. It was as if it cycled through the different possible network bridges on my machine before finally resolving to one. Though I'm not sure if that is just curl, or if it shows a wider issue on how the request is attempting to get resolved.

@davidhouweling
Copy link

For those who copied the configuration from react-transform-boilerplate (@ingro, @NeXTs, @jgoux @ustccjw, @skolmer, @jackgeek, @tkh44) and had the issue, take a look at my pull request to react-transform-boilerplate which solved it for me.

@skolmer
Copy link

skolmer commented Feb 10, 2016

The solution in my case was to add "eventsource-polyfill" to the webpack entry points.
In react-transform-boilerplate it is described as requirement for IE but in my case it fixed HMR in Firefox and Chrome too.

@skolmer
Copy link

skolmer commented Feb 10, 2016

To add to my last comment. It seems that Bitdefender is somehow buffering the server sent events and breaking HMR. Uninstalling Bitdefender or using the eventsource-polyfill is the solution if you have Bitdefender AV installed.
http://stackoverflow.com/a/30626490/1787868
http://forums.asp.net/post/5315602.aspx

@sharpoverride
Copy link

@davidhouweling Awesome, I've verified it on my machine with Sophos installed and it works.

Thank you.

@owieboy
Copy link

owieboy commented Feb 11, 2016

Removing the localhost binding did not work for me.
I'm using Chromium Version 44.0.2403.89 Built on Ubuntu 14.04, running on LinuxMint 17.2 (64-bit)
I tried running 0.12 and 4.2

@dclowd9901
Copy link

Seeing this as well for our exceptionally large build

@glenjamin
Copy link
Collaborator

Size of build is fairly unlikely to be the problem.

The things to check are noted in #36 (comment)

@dclowd9901
Copy link

@glenjamin the problem is that the heartbeat response times out. It seems as though the browser isn't "beating" quickly enough to prevent the timeout, which seems to be a downstream effect of locking during the compilation phase. I don't know enough about the particulars of the event loop and its effect on the heartbeat during processing, but the two don't seem mutually exclusive.

I'm not on windows, and there's no MITM running (unless IT installed something without my knowledge, certainly possible, but they don't seem to know anything about it either).

@glenjamin
Copy link
Collaborator

@dclowd9901 ah, I see - that must be a pretty long compile time! The simplest fix is to change the timeout setting to be longer.

@dclowd9901
Copy link

Is there a flag that I can pass through webpack-dev-server to change that? One didn't immediately pop out at me as I was browsing the code (I did see something that looked like a debounce timeout)

@glenjamin
Copy link
Collaborator

@dclowd9901 Try increasing timeout as specified here: https://github.com/glenjamin/webpack-hot-middleware#config

That setting is how long the browser waits for a heartbeat before giving up.

@lytc
Copy link

lytc commented Jul 7, 2016

I have the same issue with Vagrant/nginx proxy. Try to use Websocket instead of EventSource and it work https://github.com/lytc/webpack-hmr

@singggum3b
Copy link

I'm running a server in vmware and experienced the same problem when connect from the host machine.
It's work just fine when connect from the vm.
Strangely when i use ultimate-hot-reloading-example. i can connect normally.
Then i tried to isolate the problem , if i remove the devtool: '#eval-source-map', or

import React from 'react';
import ReactDOM from 'react-dom';

it stopped working. 😱 . Still can't figured what went wrong though.
I also have bitdefender installed.

@ywmail
Copy link

ywmail commented Sep 20, 2016

I can get the [HMR] connected in chrome dev tool, but no other info after a file compiled.
I have two webpack compiler tasks.
# webpack.dev.js:

    const hotMiddlewareScript = 'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true';

    entry: {

      'polyfills': ['./src/' + app + '/polyfills.browser.ts', hotMiddlewareScript],
      'vendor': ['./src/' + app + '/vendor.browser.ts', hotMiddlewareScript],
      'main': ['./src/' + app + '/main.browser.ts', hotMiddlewareScript]

    },

# server.js:

let telcoConfig = require('./config/webpack.dev')({ env: 'development', app: 'telco' });
let marketplaceConfig = require('./config/webpack.dev')({ env: 'development', app: 'marketplace' });
let configs = [telcoConfig, marketplaceConfig];

let compiler = webpack(configs);

let express = require('express');
let middleware = require('webpack-dev-middleware');
let app = express();

// Dev Server
configs.forEach(function (config) {
  app.use(middleware(webpack(config), {
    publicPath: config.output.publicPath
  }));
});

// Enables HMR
app.use(webpackHotMiddleware(compiler, {
  log: console.log, path: '/__webpack_hmr', heartbeat: 10 * 1000
}));

let server = app.listen(18088);

@glenjamin
Copy link
Collaborator

You need to make sure you're using the same compiler instance for both dev-middleware and hot-middleware.

In the example above you create an extra one.

@glenjamin
Copy link
Collaborator

There is a way to have more than one config on the same compiler instance, but I've not used it myself - if you look through the closed issues / pull reqs you might find a useful example.

@ywmail
Copy link

ywmail commented Sep 21, 2016

Thanks @glenjamin , I fixed the problem follow your instructions.

// Dev Server
configs.forEach(function (config) {
  let compiler = webpack(config);
  app.use(middleware(compiler, {
    publicPath: config.output.publicPath
  }));

  // Enables HMR
  app.use(webpackHotMiddleware(compiler, {
    log: console.log, path: config.output.publicPath + '__webpack_hmr', heartbeat: 3 * 1000
  }));

});

@kirkstrobeck
Copy link

kirkstrobeck commented Nov 17, 2016

I am on a mac, using express, node 7.0.0, yarn, and here are my deps. I am able to recreate this issue.

Server looks like

app.use(require('webpack-hot-middleware')(compiler));

When curling it I only get one heartbeat, then

curl: (28) Operation timed out after 10016 milliseconds with 20736 bytes received

SOLVED

Looks like the hmr was working fine, but the react-transform-hmr in my .babelrc was specified under an environment and was not being properly set, so console.log statements went thru, but not jsx revisions.

@smukkekim
Copy link

The problem for me turned out to be my antivirus - BitDefender Internet Security.
Upgrading to BitDefender 2017 resolved the issue...

@Doeke
Copy link

Doeke commented Jul 7, 2017

Bitdefender antivirus was blocking requests to http://localhost:8080/__webpack_hmr for me as well, fixed it by turning of real-time protection shield.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests