diff --git a/History.md b/History.md index 0b145d7b89..5d63c9dc9d 100644 --- a/History.md +++ b/History.md @@ -20,6 +20,11 @@ * The `meteor ...` syntax will now work for any command installed in `dev_bundle/bin`, except for Meteor's own commands. +* 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 * Node has been upgraded to version 4.6.0, a recommended security release: diff --git a/tools/utils/http-helpers.js b/tools/utils/http-helpers.js index 673da536b7..c8c9b49942 100644 --- a/tools/utils/http-helpers.js +++ b/tools/utils/http-helpers.js @@ -299,7 +299,15 @@ _.extend(exports, { // require it until we definitely need it. Console.debug("Doing HTTP request: ", options.method || 'GET', options.url); 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)) { onRequest(req);