https://github.com/vladimiry/fs-no-eperm-anymore
Reducing EPERM or other errors on win32 or other platforms using retry loop approach
https://github.com/vladimiry/fs-no-eperm-anymore
backoff backoff-strategy eperm error-handling file-system fs retry win32 windows
Last synced: about 1 year ago
JSON representation
Reducing EPERM or other errors on win32 or other platforms using retry loop approach
- Host: GitHub
- URL: https://github.com/vladimiry/fs-no-eperm-anymore
- Owner: vladimiry
- License: mit
- Created: 2017-11-25T11:35:39.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-30T13:19:28.000Z (almost 2 years ago)
- Last Synced: 2025-03-28T23:51:13.878Z (about 1 year ago)
- Topics: backoff, backoff-strategy, eperm, error-handling, file-system, fs, retry, win32, windows
- Language: TypeScript
- Homepage:
- Size: 472 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fs-no-eperm-anymore
is a Node.js module that reduces EPERM or other errors on win32 or other platforms using retry loop approach.
[](https://github.com/vladimiry/fs-no-eperm-anymore/actions)
## Notes
- Original "fs" methods are wrapped into the ES2015 Promises.
- Module exposes only the `async` functions. Retry approach is used and so it won't make much sense to `sleep` the main process just to support `sync` methods set.
- You can see some details about the `options` parameter in the [Making options more flexible](https://github.com/vladimiry/fs-no-eperm-anymore/issues/1) issue. Default `options` value:
```typescript
const options = {
items: [
{
platforms: ["win32"],
errorCodes: ["EPERM"], // https://nodejs.org/api/errors.html#errors_common_system_errors
options: {
retryIntervalMs: 100,
retryTimeoutMs: 10 * 1000,
},
},
],
};
```
## Code Example
```typescript
import {instantiate} from "fs-no-eperm-anymore";
// const fs = require("fs-no-eperm-anymore").instantiate();
// options parameter is optional
const fs = instantiate(/*options*/);
fs.rename("from.txt", "to.txt")
.then(() => console.log("Successful renaming"))
.catch((error) => console.log("Renaming failed with the error", error));
```
## Links
* https://github.com/isaacs/node-graceful-fs/pull/119 - more details about the EPERM errors.
* https://nodejs.org/api/errors.html#errors_common_system_errors - Common System Errors