Comments (4)
Thanks for posting. I did not realize that adding a directory within my "/.node-persist/storage" would cause this error. It took me a while to realize it was coming from node-persist. Removing the extra folder I created within the storage directory seems to fix the issue.
from node-persist.
ok you can use forgiveParseErrors: true
in the init options to ignore unrecognized files and directories in your storage dir
in some cases, you (or some other service) might add non-valid storage files to your storage dir, i.e. Google Drive, make this true if you'd like to ignore these files and not throw an error
https://github.com/simonlast/node-persist#async-initoptions-callback
let me know if that doesn't work
from node-persist.
I recently ran into the same problem in my project with a subfolder causing problems. Also, any other file in the cache directory other than one created by node-persist will also cause a similar unhandled exception. My biggest concern isn't about the unhandled exceptions, but the problem is that none of the cached files are being removed.
To provide a little more detail:
const NodePersist = require('node-persist');
process.on('unhandledRejection', (err, p) => {
console.log('Unhandled Rejection: %s', err.message);
if (p) {
p.catch((pErr) => console.log(`Promise Exception: ${pErr}`));
}
console.log(err.stack);
});
const cacheOptions = {
dir: path.normalize('./.cache/folder1'),
ttl: 86400 * 1000, // one day
expiredInterval: 1*60*1000 // cleanup expired cache every minute
};
const myCache = NodePersist.create(cacheOptions);
myCache.init();
If .cache/folder1 only contains files, then things work as expected. However, if a subfolder is created inside folder1 (./.cache/folder1/folder2), then during the clean up phase (expiredInterval), the unhandledRejection is triggered and no expired entries are removed from the .cache/folder1 directory.
Console Output:
Unhandled Rejection: EISDIR: illegal operation on a directory, read
Promise Exception: Error: EISDIR: illegal operation on a directory, read
Also, if there is another file in the cache location (echo 'Hello World > ./.cache/folder1/file) that was not created by node-persist, then an unhandled exception is also triggered and expired entries are not removed.
Console Output:
Unhandled Rejection: [node-persist][readFile] C:\Projects\BlackFishDashboard_Review\back\.cache\KernelRegression\New Text Document does not look like a valid storage file!
Promise Exception: Error: [node-persist][readFile] C:\Projects\BlackFishDashboard_Review\back\.cache\KernelRegression\New Text Document does not look like a valid storage file!
IMHO, I think that directories should always be skipped and that only files in the specified directory should be processed (since these are the only files that it should have been created by a node-persist instance). Invalid storage files could throw an error if desired, but the promise rejection should be caught within the node-persist module. The forgiveParseErrors: true
option could be used to suppress those error prints if the user desires. In all cases, the expired files found should still be removed.
from node-persist.
I ran into this issue as well and deleting the folder from .node-persist/storage
fixed it. Thanks for documenting this.
from node-persist.
Related Issues (20)
- Create different localstorages? Like collections HOT 1
- How to use asynchronous init() HOT 4
- Upstream dependency has a vulnerability (minimist 0.0.8 from mkdirp 0.5.1) HOT 4
- EISDIR: illegal operation on a directory, read on @eadir folders, synology NAS HOT 2
- Error: EROFS: read-only file system, mkdir '/storage' HOT 4
- Improvement: Typescript Support HOT 1
- const storage = require('../node_modules/node-persist'); causes NodeJS to throw error HOT 6
- Is there a good way to manage multiple directories? HOT 1
- [Enhancement] Storage folder inside other storage folder is a bad idea HOT 5
- Can we store node event emitter objects in this? HOT 1
- Unable to write file on google function workspace 🤯 HOT 1
- Appending files / persisting logging data
- Just a Question: Version 3 "All the *Sync functions were removed, every operation is now asynchronous" HOT 1
- node-persist error sometimes makes the application to crash HOT 6
- Getting this error intermittently: 'Error: EMFILE: too many open files' HOT 2
- Can it store binary data(buffer)? HOT 2
- Version 4 not published on npm HOT 1
- Confusing README and lack of "sync" functions HOT 4
- node-persist reading all files to RAM ? HOT 4
- Filenames on Windows are case-insensitive, ie. should use base32 instead of base64 to avoid key mismatch
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-persist.