-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
206 - Partial Content received for slow connections or large files, most browsers fail to load #1044
Comments
Definitely an edge case, but one that's sprinkled around the web not with webpack-dev-server, but with express. It seems there's an open issue for this as well. This may be with how we're using express with regard to large files, but this is probably going to be a nuanced solution specific to your environment. |
@shellscape The info is much appreciated. I was wondering what you suspect be the best plan here? Open a bug against express to figure out what a workaround would be? The bug you referenced seems to suspect an incorrect usage of Or rather, avoid using express and switch to koa-webpack? Does koa suffer from the same issue? Or avoid *-webpack-middleware altogether for external usage and only use it for localhost development? Edit So I tried a pretty simple test circumventing webpack-dev-server and just using Express standalone to ship the large file using Alternatively, I did try using a So then I tried changing webpack-dev-middleware to: // server content
// var content = context.fs.readFileSync(filename);
// content = shared.handleRangeHeaders(content, req, res);
res.setHeader("Content-Type", mime.lookup(filename) + "; charset=UTF-8");
// res.setHeader("Content-Length", content.length);
if(context.options.headers) {
for(var name in context.options.headers) {
res.setHeader(name, context.options.headers[name]);
}
}
// Express automatically sets the statusCode to 200, but not all servers do (Koa).
res.statusCode = res.statusCode || 200;
context.fs.createReadStream(filename).pipe(res)
// if(res.send) res.send(content);
// else res.end(content);
resolve(); And that seems to work properly. For some reason, if you (un-comment) and append the Content-Length header, res.setHeader("Content-Length", content.length); even with streaming, it reintroduces the 206 - Partial Content bug. |
Welp, I think I'm going to close this, as the bug is not within Express/WebpackDevServer. This is a NodeJS bug since Node 8.0.0, per expressjs/express#3392. |
@mtraynham thanks for your diligence. |
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
External (obfuscated IP)
Related
angular/angular-cli#7197
Some things I tried with the Server code
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
The text was updated successfully, but these errors were encountered: