-
Notifications
You must be signed in to change notification settings - Fork 173
Open
Description
Hello,
I tried to use this library to optimize a website speed, that worked great but sometimes a crash occurs. If you can help, that would be nice.
Log:
[22/Feb/2020:10:03:18 +0100] [upstream] Upstream started PID: 1163837
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR: internal/timers.js:279
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR: function incRefCount() {
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR: ^
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR:
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR: RangeError: Maximum call stack size exceeded
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR: at incRefCount (internal/timers.js:279:21)
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR: at insert (internal/timers.js:336:7)
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR: at active (internal/timers.js:292:3)
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR: at setTimeout (timers.js:143:3)
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR: at Cache.put (node_modules/memory-cache/index.js:34:24)
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR: at ServerResponse.res.send [as sendResponse] (app.js:69:16)
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR: at ServerResponse.res.send [as sendResponse] (app.js:70:13)
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR: at ServerResponse.res.send [as sendResponse] (app.js:70:13)
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR: at ServerResponse.res.send [as sendResponse] (app.js:70:13)
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] STDERR: at ServerResponse.res.send [as sendResponse] (app.js:70:13)
[22/Feb/2020:10:15:26 +0100] [upstream] [1163837] Upstream stopped (reason: exited spontaneously with return code 1)
Cache function into app.js
const mcache = require('memory-cache');
var cache = (duration) => {
return (req, res, next) => {
let key = '__express__' + req.originalUrl || req.url
let cachedBody = mcache.get(key)
if (cachedBody) {
res.send(cachedBody)
return
} else {
res.sendResponse = res.send
res.send = (body) => {
mcache.put(key, body, duration * 1000);
res.sendResponse(body)
}
next()
}
}
}
Have a good day'
Metadata
Metadata
Assignees
Labels
No labels