disk-memoizer
Advanced tools
Comparing version 2.2.3 to 3.0.0
@@ -188,5 +188,11 @@ "use strict"; | ||
function unlockAndReportError(err) { | ||
lockFile.unlock(lockPath, function () { | ||
callback(err); | ||
}); | ||
} | ||
function grabAndCacheCallback(err, unmarshalledData) { | ||
if (err) { | ||
return callback(err); | ||
return unlockAndReportError(err); | ||
} | ||
@@ -203,3 +209,3 @@ | ||
if (err) { | ||
return callback(err); | ||
return unlockAndReportError(err); | ||
} | ||
@@ -209,3 +215,3 @@ | ||
if (err) { | ||
return callback(err); | ||
return unlockAndReportError(err); | ||
} | ||
@@ -216,3 +222,3 @@ | ||
debug("[error] Failed saving %s. Got error: %s", cachePath, err.message); | ||
return callback(err); | ||
return unlockAndReportError(err); | ||
} | ||
@@ -219,0 +225,0 @@ lockFile.unlock(lockPath, function () { |
@@ -224,6 +224,11 @@ // Simple disk memoization and in memory LRU cache for high | ||
function unlockAndReportError(err) { | ||
lockFile.unlock(lockPath, () => { | ||
callback(err); | ||
}); | ||
} | ||
function grabAndCacheCallback(err, unmarshalledData) { | ||
if (err) { | ||
return callback(err); | ||
return unlockAndReportError(err); | ||
} | ||
@@ -240,3 +245,3 @@ | ||
if (err) { | ||
return callback(err); | ||
return unlockAndReportError(err); | ||
} | ||
@@ -246,3 +251,3 @@ | ||
if (err) { | ||
return callback(err); | ||
return unlockAndReportError(err); | ||
} | ||
@@ -256,3 +261,3 @@ | ||
); | ||
return callback(err); | ||
return unlockAndReportError(err); | ||
} | ||
@@ -259,0 +264,0 @@ lockFile.unlock(lockPath, () => { |
{ | ||
"name": "disk-memoizer", | ||
"version": "2.2.3", | ||
"version": "3.0.0", | ||
"description": "Simple disk memoization and in memory LRU cache for high latency IO responses", | ||
@@ -12,3 +12,3 @@ "main": "dist/disk_memoizer.js", | ||
"build": "babel lib/ -d dist/", | ||
"clean": "rm -r dist/* ./coverage ./.nyc_output", | ||
"clean": "rm -rf dist/* ./coverage ./.nyc_output", | ||
"prepublish": "npm run build", | ||
@@ -42,18 +42,18 @@ "postbuild": "npm run test", | ||
"devDependencies": { | ||
"babel-cli": "^6.24.1", | ||
"babel-cli": "^6.26.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"eslint": "^4.1.1", | ||
"mocha": "^3.2.0" | ||
"eslint": "^5.16.0", | ||
"mocha": "^6.0.2" | ||
}, | ||
"dependencies": { | ||
"async": "^2.3.0", | ||
"debug": "^2.6.4", | ||
"glob": "^7.1.1", | ||
"graceful-fs": "^4.1.11", | ||
"lockfile": "^1.0.3", | ||
"lru-cache": "^4.0.2", | ||
"async": "^2.6.2", | ||
"debug": "^4.1.1", | ||
"glob": "^7.1.3", | ||
"graceful-fs": "^4.1.15", | ||
"lockfile": "^1.0.4", | ||
"lru-cache": "^5.1.1", | ||
"mkdirp": "^0.5.1", | ||
"reltime": "^0.0.2", | ||
"request": "^2.81.0" | ||
"request": "^2.88.0" | ||
} | ||
} |
@@ -134,3 +134,3 @@ # disk-memoizer | ||
Copyright (c) 2017 Fluid, Inc, Bermi Ferrer <bferrer@fluid.com> | ||
Copyright (c) 2019 Astound Commerce, Inc, Bermi Ferrer <b.ferrer@astoundcommerce.com> | ||
@@ -137,0 +137,0 @@ Permission is hereby granted, free of charge, to any person obtaining |
@@ -198,2 +198,23 @@ /* eslint no-sync: 0, init-declarations: 0, max-lines: 0, max-statements: 0 */ | ||
it("should prevent race conditions with concurrent failing requests", | ||
function timedTest(done) { | ||
this.timeout(500); // eslint-disable-line | ||
const concurrentCalls = 10; | ||
const expectedErrorMessage = "Forced failure"; | ||
const memoizedFn = diskMemoizer((url, callback) => { | ||
callback(new Error(expectedErrorMessage)); | ||
}, {type: "json"}); | ||
let callbackCount = 0; | ||
[...Array(concurrentCalls)].map(() => memoizedFn("Fake URL", | ||
(err) => { | ||
callbackCount += 1; | ||
assert.equal(err.message, expectedErrorMessage); | ||
if (callbackCount === concurrentCalls) { | ||
done(); | ||
} | ||
} | ||
)); | ||
}); | ||
}); | ||
@@ -200,0 +221,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1605
61730
22
+ Addeddebug@4.4.0(transitive)
+ Addedlru-cache@5.1.1(transitive)
+ Addedms@2.1.3(transitive)
+ Addedyallist@3.1.1(transitive)
- Removeddebug@2.6.9(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedms@2.0.0(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedyallist@2.1.2(transitive)
Updatedasync@^2.6.2
Updateddebug@^4.1.1
Updatedglob@^7.1.3
Updatedgraceful-fs@^4.1.15
Updatedlockfile@^1.0.4
Updatedlru-cache@^5.1.1
Updatedrequest@^2.88.0