mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Report an error when HTTP request body is incomplete.
When a download aborts prematurely, the status code is often 200 OK, even though we probably should not proceed with any further processing of the downloaded information. This silent failure leads to problems like the dreaded "Error: ENOENT: no such file or directory, open... os.json" (#7806 and others), which were hard to diagnose properly because the failure occurred only later, when extracting a buffer that downloaded incompletely. The getUrlWithResuming helper should be able to retry after this error is thrown, which will result in a more helpful warning, even if in the most common case, i.e. MaxCDN failure, it will never actually succeed. Note that this change will not help until Meteor 1.4.2 is officially released and becomes the implementation used to download later releases. Mitigates #7806.
This commit is contained in:
@@ -78,6 +78,11 @@
|
|||||||
engine, instead of failing to start Mongo.
|
engine, instead of failing to start Mongo.
|
||||||
[#7840](https://github.com/meteor/meteor/pull/7840).
|
[#7840](https://github.com/meteor/meteor/pull/7840).
|
||||||
|
|
||||||
|
* Incomplete package downloads will now fail (and be retried several
|
||||||
|
times) instead of silently succeeding, which was the cause of the
|
||||||
|
dreaded `Error: ENOENT: no such file or directory, open... os.json`
|
||||||
|
error. [#7806](https://github.com/meteor/meteor/issues/7806)
|
||||||
|
|
||||||
## v1.4.1.2
|
## v1.4.1.2
|
||||||
|
|
||||||
* Node has been upgraded to version 4.6.0, a recommended security release:
|
* Node has been upgraded to version 4.6.0, a recommended security release:
|
||||||
|
|||||||
@@ -299,7 +299,15 @@ _.extend(exports, {
|
|||||||
// require it until we definitely need it.
|
// require it until we definitely need it.
|
||||||
Console.debug("Doing HTTP request: ", options.method || 'GET', options.url);
|
Console.debug("Doing HTTP request: ", options.method || 'GET', options.url);
|
||||||
var request = require('request');
|
var request = require('request');
|
||||||
var req = request(options, callback);
|
var req = request(options, function (error, response, body) {
|
||||||
|
const contentLength = Number(response.headers["content-length"]);
|
||||||
|
if (contentLength > 0 && body.length < contentLength) {
|
||||||
|
error = new Error(
|
||||||
|
"Expected " + contentLength + " bytes in request body " +
|
||||||
|
"but received only " + body.length);
|
||||||
|
}
|
||||||
|
return callback.call(this, error, response, body);
|
||||||
|
});
|
||||||
|
|
||||||
if (_.isFunction(onRequest)) {
|
if (_.isFunction(onRequest)) {
|
||||||
onRequest(req);
|
onRequest(req);
|
||||||
|
|||||||
Reference in New Issue
Block a user