Coder Social home page Coder Social logo

vladimiry / fs-no-eperm-anymore Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 435 KB

Reducing EPERM or other errors on win32 or other platforms using retry loop approach

License: MIT License

TypeScript 100.00%
error-handling eperm win32 windows fs file-system backoff-strategy backoff retry

fs-no-eperm-anymore's People

Contributors

dependabot[bot] avatar vladimiry avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

lgtm-migrator

fs-no-eperm-anymore's Issues

Making options more flexible

Like specifying custom parameters for the specific functions and error codes, following the inheritance ideas. So options might look like this:

const options = {
    platform: "win32", // optional
    retryIntervalMs: 50,
    retryTimeoutMs: 30 * 1000,
    retryCountLimit: 123, // optional
    errorCodes: ["EPERM"],
    errorCodesMap: {  // optional
        EACCS: {
            retryIntervalMs: 500, // optional
            retryTimeoutMs: 10 * 1000, // optional
            retryCountLimit: 345, // optional
        },
    },
    functionsMap: { // optional
        rename: {
            platform: "linux", // optional
            retryIntervalMs: 50, // optional
            retryTimeoutMs: 30 * 1000, // optional
            retryCountLimit: 45746,  // optional
            errorCodesMap: {  // optional
                EPERM: {
                    retryIntervalMs: 5454,  // optional
                    retryTimeoutMs: 123 * 1000,  // optional
                    retryCountLimit: 662,  // optional
                },
                EEXIST: {
                    retryIntervalMs: 1500,  // optional
                    retryTimeoutMs: 5 * 1000,  // optional
                    retryCountLimit: 345,  // optional
                },
            },
        },
    },
};

Where:

  • platform and retryCountLimit are always optional. If the are no values specified, then retry executes for any platform and number of retry attempts is not limited by the retryCountLimit value (only by the retryIntervalMs and retryTimeoutMs).
  • retryIntervalMs and retryTimeoutMs are optional on any level except the top level. Means if there is no custom values defined on the errorCodesMap / functionsMap levels/sub-levels, then default values defined on the top level take place.
  • errorCodes basically can be an empty array, then no error handling happens - any happened error re-throws (goes up).
  • platform can be specified on either top or Options.functionsMap[<function name>] levels.

So retryIntervalMs, retryTimeoutMs, retryTimeoutMs resolving occurs in the inherited way (from the most narrow object, up to the wider/global object):

  1. Options.functionsMap[<function name>].errorCodes[<error code>]
  2. Options.functionsMap[<function name>]
  3. Options.errorCodesMap[<error code>]
  4. Options (top level).

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.