-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error: Unhandled Rejection at: Promise[object Promise] reason:Error: EISDIR: illegal operation on a directory, read #118
Comments
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. |
ok you can use
https://github.com/simonlast/node-persist#async-initoptions-callback let me know if that doesn't work |
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:
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:
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:
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 |
I ran into this issue as well and deleting the folder from |
In case there is a folder in the same directory as the cache file, then this folder is accessed as a file which lead to the ugly error above.
Easy workaround: put all cache files into their own folder.
This happens when the cleanup function is triggered.
readFile (node_modules\node-persist\src\local-storage.js:302)
fs.readdir (node_modules\node-persist\src\local-storage.js:286)
[ async function ] (Unknown Source:undefined)
fs.readdir (node_modules\node-persist\src\local-storage.js:278)
(anonymous function) (fs.js:135)
[ FSREQWRAP ] (Unknown Source:undefined)
init (inspector_async_hook.js:22)
emitInitNative (async_hooks.js:131)
fs.readdir (fs.js:897)
fs.exists (node_modules\node-persist\src\local-storage.js:278)
cb (fs.js:312)
[ FSREQWRAP ] (Unknown Source:undefined)
init (inspector_async_hook.js:22)
emitInitNative (async_hooks.js:131)
fs.exists (fs.js:310)
Promise (node_modules\node-persist\src\local-storage.js:275)
readDirectory (node_modules\node-persist\src\local-storage.js:273)
data (node_modules\node-persist\src\local-storage.js:116)
keys (node_modules\node-persist\src\local-storage.js:120)
removeExpiredItems (node_modules\node-persist\src\local-storage.js:238)
The text was updated successfully, but these errors were encountered: