@socketsecurity/lib 5.9.0 → 5.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/fs.js +42 -12
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [5.9.1](https://github.com/SocketDev/socket-lib/releases/tag/v5.9.1) - 2026-03-14
9
+
10
+ ### Fixed
11
+
12
+ - **fs**: `safeDelete()` and `safeDeleteSync()` now properly implement retry logic
13
+ - Previously `maxRetries` was incorrectly passed as `concurrency` to del (parallelism, not retries)
14
+ - `safeDelete()` now wraps `deleteAsync()` with `pRetry()` for exponential backoff
15
+ - `safeDeleteSync()` implements sync retry loop with `Atomics.wait()` for non-blocking sleep
16
+ - Both use `backoffFactor: 2` (delay doubles each retry: 200ms → 400ms → 800ms by default)
17
+ - `maxRetries` and `retryDelay` options in `RemoveOptions` now work as documented
18
+
8
19
  ## [5.9.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.9.0) - 2026-03-14
9
20
 
10
21
  ### Changed
package/dist/fs.js CHANGED
@@ -53,6 +53,7 @@ module.exports = __toCommonJS(fs_exports);
53
53
  var import_process = require("./constants/process");
54
54
  var import_arrays = require("./arrays");
55
55
  var import_del = require("./external/del");
56
+ var import_promises = require("./promises");
56
57
  var import_globs = require("./globs");
57
58
  var import_parse = require("./json/parse");
58
59
  var import_objects = require("./objects");
@@ -527,12 +528,23 @@ async function safeDelete(filepath, options) {
527
528
  shouldForce = true;
528
529
  }
529
530
  }
530
- await (0, import_del.deleteAsync)(patterns, {
531
- concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,
532
- dryRun: false,
533
- force: shouldForce,
534
- onlyFiles: false
535
- });
531
+ const maxRetries = opts.maxRetries ?? defaultRemoveOptions.maxRetries;
532
+ const retryDelay = opts.retryDelay ?? defaultRemoveOptions.retryDelay;
533
+ await (0, import_promises.pRetry)(
534
+ async () => {
535
+ await (0, import_del.deleteAsync)(patterns, {
536
+ dryRun: false,
537
+ force: shouldForce,
538
+ onlyFiles: false
539
+ });
540
+ },
541
+ {
542
+ retries: maxRetries,
543
+ baseDelayMs: retryDelay,
544
+ backoffFactor: 2,
545
+ signal: opts.signal
546
+ }
547
+ );
536
548
  }
537
549
  function safeDeleteSync(filepath, options) {
538
550
  const opts = { __proto__: null, ...options };
@@ -557,12 +569,30 @@ function safeDeleteSync(filepath, options) {
557
569
  shouldForce = true;
558
570
  }
559
571
  }
560
- (0, import_del.deleteSync)(patterns, {
561
- concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,
562
- dryRun: false,
563
- force: shouldForce,
564
- onlyFiles: false
565
- });
572
+ const maxRetries = opts.maxRetries ?? defaultRemoveOptions.maxRetries;
573
+ const retryDelay = opts.retryDelay ?? defaultRemoveOptions.retryDelay;
574
+ let lastError;
575
+ let delay = retryDelay;
576
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
577
+ try {
578
+ (0, import_del.deleteSync)(patterns, {
579
+ dryRun: false,
580
+ force: shouldForce,
581
+ onlyFiles: false
582
+ });
583
+ return;
584
+ } catch (error) {
585
+ lastError = error;
586
+ if (attempt < maxRetries) {
587
+ const waitMs = delay;
588
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, waitMs);
589
+ delay *= 2;
590
+ }
591
+ }
592
+ }
593
+ if (lastError) {
594
+ throw lastError;
595
+ }
566
596
  }
567
597
  async function safeMkdir(path, options) {
568
598
  const fs = /* @__PURE__ */ getFs();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/lib",
3
- "version": "5.9.0",
3
+ "version": "5.9.1",
4
4
  "packageManager": "pnpm@10.32.1",
5
5
  "license": "MIT",
6
6
  "description": "Core utilities and infrastructure for Socket.dev security tools",
@@ -734,7 +734,7 @@
734
734
  "@socketregistry/is-unicode-supported": "1.0.5",
735
735
  "@socketregistry/packageurl-js": "1.3.5",
736
736
  "@socketregistry/yocto-spinner": "1.0.25",
737
- "@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.8.2",
737
+ "@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.9.0",
738
738
  "@types/node": "24.9.2",
739
739
  "@typescript/native-preview": "7.0.0-dev.20250920.1",
740
740
  "@vitest/coverage-v8": "4.0.3",