fix: Use correct property to figure out LRU cache size
MODIFY
lib/basedriver/helpers.js
lib/basedriver/helpers.js
@@ -35,14 +35,14 @@ const DEFAULT_BASENAME = 'appium-app';
const APP_DOWNLOAD_TIMEOUT_MS = 120 * 1000;
process.on('exit', () => {
- if (!APPLICATIONS_CACHE.length) {
+ if (APPLICATIONS_CACHE.itemCount === 0) {
return;
}
const appPaths = APPLICATIONS_CACHE.values()
.map(({fullPath}) => fullPath);
logger.debug(`Performing cleanup of ${appPaths.length} cached ` +
- `${util.pluralize('application', appPaths.length)}`);
+ util.pluralize('application', appPaths.length));
for (const appPath of appPaths) {
try {
// Asynchronous calls are not supported in onExit handler

MODIFY
lib/express/idempotency.js
lib/express/idempotency.js
@@ -19,7 +19,17 @@ const IDEMPOTENT_RESPONSES = new LRU({
const MONITORED_METHODS = ['POST', 'PATCH'];
const IDEMPOTENCY_KEY_HEADER = 'x-idempotency-key';
-process.on('exit', () => IDEMPOTENT_RESPONSES.reset());
+process.on('exit', () => {
+ const resPaths = IDEMPOTENT_RESPONSES.values()
+ .map(({response}) => response)
+ .filter(Boolean);
+ for (const resPath of resPaths) {
+ try {
+ // Asynchronous calls are not supported in onExit handler
+ fs.rimrafSync(resPath);
+ } catch (ign) {}
+ }
+});
function cacheResponse (key, req, res) {

fix: Use correct property to figure out LRU cache size (#435)