Giter Site home page Giter Site logo

error: Unhandled Rejection at: Promise[object Promise] reason:Error: EISDIR: illegal operation on a directory, read about node-persist HOT 4 OPEN

engelchrisi avatar engelchrisi commented on August 14, 2024 1
error: Unhandled Rejection at: Promise[object Promise] reason:Error: EISDIR: illegal operation on a directory, read

from node-persist.

Comments (4)

lostinadaydream avatar lostinadaydream commented on August 14, 2024

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.

akhoury avatar akhoury commented on August 14, 2024

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.

jerrens avatar jerrens commented on August 14, 2024

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.

formaldehydeson avatar formaldehydeson commented on August 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.