Skip to content

Commit

Permalink
v1.2.62
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-person committed Dec 28, 2022
1 parent 73f6ad2 commit 8779142
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.2.62

- fix throw error on empty files

## v1.2.61

- fix missing cors origin header when port and crossDomainPort are the same
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rammerhead",
"version": "1.2.61",
"version": "1.2.62",
"description": "User friendly web proxy powered by testcafe-hammerhead",
"main": "src/index.js",
"scripts": {
Expand Down
7 changes: 6 additions & 1 deletion src/classes/RammerheadJSFileCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class RammerheadJSFileCache {
this.lruMarker = new LRUCache({
max: maxItems,
maxSize: jsCacheSize,
sizeCalculation: n => n,
sizeCalculation: n => n || 1,
dispose(_, key) {
fs.unlinkSync(path.join(diskJsCachePath, key));
}
Expand All @@ -55,6 +55,11 @@ class RammerheadJSFileCache {
initFileList.sort((a, b) => a.size - b.size);

for (const file of initFileList) {
if (!file.size) {
// writing probably got interrupted. so we delete the corrupted file
fs.unlinkSync(path.join(diskJsCachePath, file.key));
continue;
}
this.lruMarker.set(file.key, file.size, {
noDisposeOnSet: true
});
Expand Down
2 changes: 1 addition & 1 deletion src/classes/RammerheadJSMemCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class RammerheadJSMemCache {
constructor(jsCacheSize) {
this.lru = new LRUCache({
maxSize: jsCacheSize,
sizeCalculation: n => n.length
sizeCalculation: n => n.length || 1
});
}
get(key) {
Expand Down
5 changes: 4 additions & 1 deletion src/util/addJSDiskCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ module.exports = async function (jsCache) {
const md5 = (data) => crypto.createHash('md5').update(data).digest('hex');

cacheGet = async (key) => await jsCache.get(md5(key));
cacheSet = async (key, value) => await jsCache.set(md5(key), value);
cacheSet = async (key, value) => {
if (!value) return;
await jsCache.set(md5(key), value);
}
};

// patch ScriptResourceProcessor
Expand Down

0 comments on commit 8779142

Please sign in to comment.