1

I am developping a web service in Go which delegates its UI to a vue.js website packaged with webpack.

My Go service is responsible for hosting the UI and a REST API that the UI use.

In development mode, I would want to benefit from the vue.js and webpack tooling (inotify-based auto-reload for instance) so I added a switch in my Go program that does this:

var handler http.Handler

if isDevelopment {
    // url below points to the webpack standalone
    // development server, at http://localhost:8080.
    proxy := httputil.NewSingleHostReverseProxy(url)
    proxy.FlushInterval = time.Millisecond * 100
    handler = proxy
} else {
    handler = http.FileServer(http.Dir("www"))
}

So basically, in development mode I can launch webpack's development server (with npm run dev) and my Go program delegates all the UI requests to it.

This works wonders except that after a couple of seconds, Chrome complains that:

GET http://localhost:9999/__webpack_hmr net::ERR_INCOMPLETE_CHUNKED_ENCODING

The auto-refresh stops working for a while and eventually comes back, but its way slower than if I directly connect to webpack's standalone server.

I think could track down the problem in Go's httputil.ReverseProxy and I believe it doesn't have any specific code to handle event sources properly.

Is this a know issue ? Is there anything I could do to make my Go reverse proxy event source aware/compatible ?

ereOn
  • 53,676
  • 39
  • 161
  • 238
  • 1
    [it might be your anti-virus software](https://stackoverflow.com/a/29990521/532430). Alternatively, it might be because both Chrome and Go support HTTP/2 but node doesn't (don't quote me on that). – thwd Jul 17 '17 at 21:36
  • @thwd: I don't have an anti-virus (it's a corporate setting - we have other security mechanisms in place, but not that). When I contact the node server directly, it does work flawlessly (with Chrome) so I still suspect Go to be guilty somehow. – ereOn Jul 18 '17 at 14:55

0 Answers0