summaryrefslogtreecommitdiff
path: root/deps/npm/lib/utils/npm-registry-client/get.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/utils/npm-registry-client/get.js')
-rw-r--r--deps/npm/lib/utils/npm-registry-client/get.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/deps/npm/lib/utils/npm-registry-client/get.js b/deps/npm/lib/utils/npm-registry-client/get.js
index 062244df3a..375bb5f972 100644
--- a/deps/npm/lib/utils/npm-registry-client/get.js
+++ b/deps/npm/lib/utils/npm-registry-client/get.js
@@ -119,6 +119,13 @@ function get_ (uri, timeout, cache, stat, data, nofollow, staleOk, cb) {
}
GET(uri, etag, nofollow, function (er, remoteData, raw, response) {
+ // if we get an error talking to the registry, but we have it
+ // from the cache, then just pretend we got it.
+ if (er && cache) {
+ er = null
+ response = {statusCode: 304}
+ }
+
if (response) {
log.silly([response.statusCode, response.headers], "get cb")
if (response.statusCode === 304 && etag) {
@@ -128,6 +135,10 @@ function get_ (uri, timeout, cache, stat, data, nofollow, staleOk, cb) {
}
data = remoteData
+ if (!data) {
+ er = new Error("failed to fetch from registry: " + uri)
+ }
+
if (er) return cb(er, data, raw, response)
// just give the write the old college try. if it fails, whatever.