October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Node.js 24 Runbook: Add a Retention Gate Before Deleting Campaign Media

A practical Node.js 24 runbook for checking retention eligibility before removing campaign images or videos, with guidance on unlink, rm, recursion, and retries.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Evaluate the applicable retention policy before calling any filesystem removal API. In Node.js 24, unlink removes one file or symbolic link, while rm can remove a file or directory; neither chooses a retention period, confirms legal compliance, or records policy approval for your application.

Run the retention decision before filesystem deletion

Treat eligibility and removal as separate steps: the policy decision authorizes or blocks deletion; Node.js performs the authorized filesystem operation. The Node.js v24.20.0 File system API documentation describes removal mechanics, not campaign-retention rules.

As an Amazon Associate I earn from qualifying purchases.

  1. Load the asset record. Retrieve the campaign image or video record and the metadata your organization’s authoritative retention policy needs.
  2. Evaluate the applicable rule. Check the policy and any relevant hold or approval state. The fields, rules, and values are application-specific; Node.js does not define them.
  3. Stop unless deletion is affirmatively allowed. If the decision blocks deletion, or cannot establish permission, do not call unlink or rm. Record the decision and reason in your application’s audit mechanism.
  4. Resolve and constrain the target. Obtain the intended path from trusted asset metadata. Match the operation and scope to what the policy decision authorizes; do not broaden a single-asset decision into recursive directory deletion.
  5. Perform the authorized operation and handle its result. Await the filesystem call, handle errors, and record the deletion result in your application’s audit mechanism. The Node.js API reference does not promise to create an audit trail.

Choose unlink or rm by target and scope

API Target it removes Scope and relevant behavior
unlink / fsPromises.unlink() A file or symbolic link Does not remove a directory, whether empty or not. Use for an individual file or symbolic link.
rm / fsPromises.rm(path, options) Files and directories Use for an individual target or, with recursive: true, an explicitly authorized directory tree. Recursion is off by default.

The v24.20.0 documentation describes fsPromises.rm as removing “files and directories (modeled on the standard POSIX rm utility).” For recursive directory removal, use rm; recursive fs.rmdir behavior is deprecated.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use rm options deliberately

In the Node.js v24.20.0 API, fsPromises.rm(path, options) fulfills with undefined on success. Its documented defaults are conservative: it does not recursively remove directories, suppress missing-path errors, or retry by default.

#1 Best Overall
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
Option Documented default Effect and decision
recursive false Set to true only when the authorized target is a directory tree that should be removed recursively.
force false When enabled, suppresses errors for a missing path. Decide explicitly whether a missing target counts as success in your workflow.
maxRetries 0 Maximum retries for documented retryable errors in recursive mode. Retries do not make deletion eligible.
retryDelay 100 ms Delay between retries in recursive mode. Choose retry behavior for operational needs, not as a retention control.

When retries are configured for recursive removal, the documentation lists EBUSY, EMFILE, ENFILE, ENOTEMPTY, and EPERM as retryable error classes. Retry settings apply only when recursive is true.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Illustrative Node.js 24 implementation

This example shows the sequence, not a ready-made policy or complete production implementation. The policy evaluator, asset model, path authorization, error handling, and audit storage must be supplied by the application.

Rank #2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
  • Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
import { rm, unlink } from 'node:fs/promises';

async function deleteEligibleAsset(asset, policy, { directory = false } = {}) {
  // Implement this check from the organization's authoritative retention policy.
  // It must account for applicable holds and approvals before any removal call.
  const decision = await policy.evaluate(asset);
  if (!decision.allowed) {
    return { deleted: false, reason: decision.reason };
  }

  // Choose only the scope authorized by the policy decision.
  if (directory) {
    await rm(asset.path, { recursive: true });
  } else {
    await unlink(asset.path);
  }

  return { deleted: true };
}

For a production job, ensure the policy decision authorizes the actual path and scope being removed, and add application-level logging for both blocked decisions and filesystem outcomes. If the job needs to tolerate a missing path or retry transient failures, configure those behaviors explicitly; neither force: true nor recursive deletion replaces the retention gate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

SaleBestseller No. 1
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$129.99
Bestseller No. 2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
Bestseller No. 3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.80
Bestseller No. 4
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$208.99
Best Value
Sale
UnionSine 500GB Ultra Slim Portable External Hard Drive HDD-USB 3.0
  • [Upgraded Version] - This external hard drive features a mirrored logo stripe combined with a striped anti-slip design, and the rounded corners of the casing make it easier to grip. The stripes also have a heat dissipation function, ensuring stable and fast data transfer.
  • 【Ultra-thin and quiet】 - The motherboard adopts JMicron 578 noise-free solution, giving you a quiet working environment. Lightweight and portable size designed to fit in your pocket for easy portability.
  • 【Ultra-Fast Data Transfers】 - Pairing this external hard drive with JMicron 578 solution USB 3.0 and USB 2.0 interfaces enables blazing-fast data transfer. It boasts theoretical read speeds of up to 125MB/s and write speeds of up to 103MB/s.
  • 【Plug and Play】 - With no software to install, just plug it in and the drive is ready to use.The hard disk chip is wrapped with an aluminum anti-interference layer to increase heat dissipation and protect data.
  • 【What You Get】 - 1 x Portable Hard Drive, 1 x USB 3.0 Cable, 1 x User Manual, Gift-type shell packaging ,Three-year manufacturer's warranty and free technical support services.
Rank #4
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
  • Easily store and access 4TB of content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
Rank #3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
  • Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.