Skip to content

206 - Partial Content received for slow connections or large files, most browsers fail to load #1044

Closed
@mtraynham

Description

@mtraynham

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Accessing webpack content on a slow connection or against a large file (like a vendor.js file) can result in a 206 - Partial Content. Within Chrome (v. 60.0.3112.101) this results in a net::ERR_CONTENT_LENGTH_MISMATCH, as the content-length header doesn't match the downloaded file, failing the download completely and the page will fail to load.

Locally (using localhost, 127.0.0.1 or 0.0.0.0) it seems to fail much slower, at almost exactly 3 minutes 58 seconds (I'm using wget to rate limit the download). Externally to the machine, large files will fail anywhere from 5 - 20 seconds. The latter here is the problem, accessing the dev-server externally with larger bundles will almost certainly fail to load.

If the current behavior is a bug, please provide the steps to reproduce.
With any webpack-dev-server running, download a somewhat large file using Webpack.

Local
> wget 127.0.0.1:3000/vendor.js --limit-rate=20k

--2017-08-15 13:44:56--  http://127.0.0.1:3000/vendor.js
Connecting to 127.0.0.1:3000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5900535 (5.6M) [application/javascript]
Saving to: ‘vendor.js’  ---  4.64M  20.2KB/s    in 3m 58s

2017-08-15 13:48:54 (20.0 KB/s) - Connection closed at byte 4867381. Retrying.

--2017-08-15 13:48:55--  (try: 2)  http://127.0.0.1:3000/vendor.js
Connecting to 127.0.0.1:3000... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 5900535 (5.6M), 1033154 (1009K) remaining [application/javascript]
Saving to: ‘vendor.js’
External (obfuscated IP)
wget 8.8.8.8:3000/vendor.js --limit-rate=20k
--2017-08-15 17:29:48--  http://8.8.8.8:3000/vendor.js
Connecting to 8.8.8.8:3000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5900535 (5.6M) [application/javascript]
Saving to: “vendor.js” --- 374,074     20.0K/s   in 18s     

2017-08-15 17:30:06 (20.0 KB/s) - Connection closed at byte 374074. Retrying.

--2017-08-15 17:30:07--  (try: 2)  http://8.8.8.8:3000/vendor.js
Connecting to 8.8.8.8:3000... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 5900535 (5.6M), 5526461 (5.3M) remaining [application/javascript]
Saving to: “vendor.js” --- 775,430     20.2K/s   in 19s     

2017-08-15 17:30:27 (20.1 KB/s) - Connection closed at byte 775430. Retrying.

--2017-08-15 17:30:29--  (try: 3)  http://8.8.8.8:3000/vendor.js
Connecting to 8.8.8.8:3000... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 5900535 (5.6M), 5125105 (4.9M) remaining [application/javascript]
Saving to: “vendor.js” --- 1,176,786   20.2K/s   in 19s     

2017-08-15 17:30:48 (20.1 KB/s) - Connection closed at byte 1176786. Retrying.

--2017-08-15 17:30:51--  (try: 4)  http://8.8.8.8:3000/vendor.js
Connecting to 8.8.8.8:3000... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 5900535 (5.6M), 4723749 (4.5M) remaining [application/javascript]
Saving to: “vendor.js” --- 1,540,100   20.0K/s   in 18s     

2017-08-15 17:31:09 (20.0 KB/s) - Connection closed at byte 1540100. Retrying.

--2017-08-15 17:31:13--  (try: 5)  http://8.8.8.8:3000/vendor.js
Connecting to 8.8.8.8:3000... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 5900535 (5.6M), 4360435 (4.2M) remaining [application/javascript]
Saving to: “vendor.js” --- 1,903,414   20.0K/s   in 18s
Related

angular/angular-cli#7197

Some things I tried with the Server code
  • Setting a huge timeout
    app.use(function(req, res, next){
        res.setTimeout(4800000, function(){
            console.log('Request has timed out.');
            res.send(408);
        });
        next();
    });
  • Removing the Promise from Webpack-Dev-Middleware (didn't realize Express allowed promises)

What is the expected behavior?
It ships the full content.

Please mention your webpack and Operating System version.
Webpack: 3.5
Webpack-Dev-Server: 2.7
Linux Mint 18.3, Mac OSX Sierra

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions