From 40d92283f42f384205187cdea71108c8218b9a17 Mon Sep 17 00:00:00 2001 From: Axey Endres Date: Fri, 3 Jul 2026 09:23:31 -0300 Subject: [PATCH 1/4] update docs --- scripting/node-fs.mdx | 47 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 38 deletions(-) diff --git a/scripting/node-fs.mdx b/scripting/node-fs.mdx index 12cd2bd..9a60aa2 100644 --- a/scripting/node-fs.mdx +++ b/scripting/node-fs.mdx @@ -38,7 +38,7 @@ Currently the file directory is composed of two folder: └── tmp/ # Temporary directory, R/W access ``` -You can create directories where you want as permissions are not enforced yet. +You can create directories anywhere. Permissions are enforced for the owner (user) but not for group or others. All files are opened in `w+`. @@ -99,62 +99,33 @@ behave differently from traditional Node.js environments. ### Symbolic Links and Hard Links -Symbolic links and hard links are not supported in the EdgeScripting runtime -yet. +Symbolic links are supported. `symlink()`, `symlinkSync()`, `readlink()`, `readlinkSync()`, and `lstat()` work as expected. -The following operations will throw errors or behave unexpectedly: -- `symlink()`, `symlinkSync()` - Creating symbolic links -- `readlink()`, `readlinkSync()` - Reading symbolic links -- `link()`, `linkSync()` - Creating hard links -- `lstat()` may not distinguish between files and symlinks correctly +Hard links are not supported. `link()` and `linkSync()` will throw errors. -**Workaround:** Use `copyFile()` instead of creating links, or restructure -your application to avoid link dependencies. - ### File Statistics - Timestamps -File modification and access times are not reliably available yet. - - -The following `Stats` object properties may return incorrect or placeholder values: +All `Stats` timestamp properties are supported and return correct values: - `atime` - Last access time - `mtime` - Last modification time - `ctime` - Last status change time -- `atimeMs`, `mtimeMs`, `ctimeMs` - Millisecond timestamps -- `birthtime`, `birthtimeMs` - File creation time - +- `birthtime` - File creation time **Reliable Stats properties:** - `size` - File size in bytes - `isFile()` - Check if entry is a file - `isDirectory()` - Check if entry is a directory -**Example of unreliable usage:** -```typescript -// DON'T rely on timestamps -const stats = await fs.stat("file.txt"); -console.log(stats.mtime); // May be incorrect! - -// DO rely on size and type checks -console.log(stats.size); // Reliable -console.log(stats.isFile()); // Reliable -``` - ### File and Directory Permissions -All files and directories effectively have read/write permissions in the -sandboxed environment (`644`) and are owned by the current (non root) user -(uid=1000, gid=1000). +File and directory permissions are supported for the **owner (user)** bits. `chmod()` and `chmodSync()` work, and `Stats.mode` reflects the permissions you set. `access()` respects owner-level read, write, and execute bits. -Permission-related operations have limited effect: -- `chmod()`, `chmodSync()` - Not supported -- `chown()`, `chownSync()` - Not supported -- `Stats.mode` - Won't reflect actual permissions -- Permission checks via `access()` - Will mostly tell you if a file exists or - not. +**Group and others** permission bits are accepted but have no effect — the sandboxed environment always runs as the file owner (uid=1000, gid=1000), so only the user/owner bits matter. + +`chown()` and `chownSync()` have no effect; ownership is fixed to uid=1000, gid=1000. From 6966833d27533719c5a35fa8f06542a182e2670d Mon Sep 17 00:00:00 2001 From: Axey Endres Date: Fri, 3 Jul 2026 09:27:46 -0300 Subject: [PATCH 2/4] details --- scripting/node-fs.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripting/node-fs.mdx b/scripting/node-fs.mdx index 9a60aa2..f9276f5 100644 --- a/scripting/node-fs.mdx +++ b/scripting/node-fs.mdx @@ -111,6 +111,7 @@ All `Stats` timestamp properties are supported and return correct values: - `atime` - Last access time - `mtime` - Last modification time - `ctime` - Last status change time +- `atimeMs`, `mtimeMs`, `ctimeMs` - Millisecond timestamps - `birthtime` - File creation time **Reliable Stats properties:** @@ -123,7 +124,7 @@ All `Stats` timestamp properties are supported and return correct values: File and directory permissions are supported for the **owner (user)** bits. `chmod()` and `chmodSync()` work, and `Stats.mode` reflects the permissions you set. `access()` respects owner-level read, write, and execute bits. -**Group and others** permission bits are accepted but have no effect — the sandboxed environment always runs as the file owner (uid=1000, gid=1000), so only the user/owner bits matter. +**Group and others** permission bits are accepted but have no effect: the sandboxed environment always runs as the file owner (uid=1000, gid=1000), so only the user/owner bits matter. `chown()` and `chownSync()` have no effect; ownership is fixed to uid=1000, gid=1000. From ef7e05b72b580780a3cb03caf742618338e9586b Mon Sep 17 00:00:00 2001 From: Axey Endres Date: Fri, 3 Jul 2026 09:32:36 -0300 Subject: [PATCH 3/4] details --- scripting/node-fs.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripting/node-fs.mdx b/scripting/node-fs.mdx index f9276f5..0aa46ab 100644 --- a/scripting/node-fs.mdx +++ b/scripting/node-fs.mdx @@ -108,16 +108,16 @@ Hard links are not supported. `link()` and `linkSync()` will throw errors. ### File Statistics - Timestamps All `Stats` timestamp properties are supported and return correct values: -- `atime` - Last access time -- `mtime` - Last modification time -- `ctime` - Last status change time -- `atimeMs`, `mtimeMs`, `ctimeMs` - Millisecond timestamps -- `birthtime` - File creation time **Reliable Stats properties:** - `size` - File size in bytes - `isFile()` - Check if entry is a file - `isDirectory()` - Check if entry is a directory +- `atime` - Last access time +- `mtime` - Last modification time +- `ctime` - Last status change time +- `atimeMs`, `mtimeMs`, `ctimeMs` - Millisecond timestamps +- `birthtime` - File creation time ### File and Directory Permissions From ca950e4b4f9c8cf08e2c4827b3dc57c7a72670df Mon Sep 17 00:00:00 2001 From: Axey Endres Date: Fri, 3 Jul 2026 09:47:20 -0300 Subject: [PATCH 4/4] example --- scripting/node-fs.mdx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/scripting/node-fs.mdx b/scripting/node-fs.mdx index 0aa46ab..9d6fb80 100644 --- a/scripting/node-fs.mdx +++ b/scripting/node-fs.mdx @@ -438,6 +438,39 @@ BunnySDK.net.http.serve(async (request: Request) => { }); ``` +### Example 6: Symbolic Links + +```typescript +import * as fs from "node:fs/promises"; +import * as BunnySDK from "@bunny.net/edgescript-sdk"; + +BunnySDK.net.http.serve(async (request: Request) => { + const original = "/tmp/original.txt"; + const link = "/tmp/link.txt"; + + try { + await fs.writeFile(original, "hello from original", "utf-8"); + + // Create a symbolic link pointing to the original file + await fs.symlink(original, link); + + // Reading through the symlink is transparent + const content = await fs.readFile(link, "utf-8"); + + // lstat inspects the link itself, not the target + const linkStats = await fs.lstat(link); + const target = await fs.readlink(link); + + return new Response( + JSON.stringify({ content, isSymlink: linkStats.isSymbolicLink(), target }), + { headers: { "content-type": "application/json" } } + ); + } catch (error) { + return new Response(`Error: ${error.message}`, { status: 500 }); + } +}); +``` + ## References - [Node.js File System Documentation](https://nodejs.org/api/fs.html) - Complete Node.js fs module reference