Skip to content

Virtual File System

Thunder provides a sandboxed, in-memory Virtual File System (VFS) so that code using node:fs works without access to the host file system. The VFS is scoped to each isolate and is completely ephemeral — all data is lost when the isolate is recycled.

PathModeSourcePurpose
/bundleRead-onlyDeployed function bundleApplication code, static assets, configuration files packaged with the function.
/tmpRead-writeEmpty at startupScratch space for caches, temporary files, intermediate data. Quota-enforced.
/dev/nullWrite-onlySinkDiscards all writes. Reads return EOF.

Any path outside these mount points returns ENOENT.


Writable space under /tmp is constrained by two quotas to prevent a single function from exhausting isolate memory.

ParameterDefaultCLI flagEnv var
Total writable bytes10 MiB--vfs-total-quota-bytesEDGE_RUNTIME_VFS_TOTAL_QUOTA_BYTES
Max single file bytes5 MiB--vfs-max-file-bytesEDGE_RUNTIME_VFS_MAX_FILE_BYTES

When a write would exceed either limit, the operation fails with ENOSPC.

import { writeFileSync } from "node:fs";
// This succeeds if within quota
writeFileSync("/tmp/data.json", JSON.stringify(payload));
// This throws ENOSPC if the file exceeds vfsMaxFileBytes
try {
writeFileSync("/tmp/large.bin", hugeBuffer);
} catch (err) {
console.error(err.code); // "ENOSPC"
}

FunctionSyncAsyncNotes
readFileSync / readFileYesYesReturns Buffer or string depending on encoding option.
readdirSync / readdirYesYesReturns file and directory names. Supports withFileTypes.
statSync / statYesYesReturns size, mtime, isFile, isDirectory.
lstatSync / lstatYesYesSame as stat (no symlinks in VFS).
existsSyncYesReturns boolean.
accessSync / accessYesYesChecks existence and permissions.
readlinkSync / readlinkYesYesAlways throws EOPNOTSUPP (no symlinks).
FunctionSyncAsyncNotes
writeFileSync / writeFileYesYesCreates or overwrites a file. Enforces quotas.
appendFileSync / appendFileYesYesAppends to a file. Enforces quotas.
mkdirSync / mkdirYesYesCreates directories. Supports recursive.
unlinkSync / unlinkYesYesRemoves a file. Frees quota.
rmdirSync / rmdirYesYesRemoves an empty directory.
rmSync / rmYesYesSupports recursive and force.
renameSync / renameYesYesMoves/renames within /tmp.
copyFileSync / copyFileYesYesCopies within or into /tmp. Enforces quotas.

These operations are intentionally not available:

  • Symlinks (symlink, link)
  • File permissions (chmod, chown)
  • File watchers (watch, watchFile)
  • File descriptors (open, read, write, close — low-level fd API)
  • Streams (createReadStream, createWriteStream)

Calling unsupported operations throws with code EOPNOTSUPP.


The VFS uses standard Node.js SystemError codes:

CodeMeaning
ENOENTFile or directory not found.
ENOTDIRA component of the path is not a directory.
EISDIRExpected a file but found a directory.
EROFSWrite attempted on a read-only mount (/bundle).
ENOSPCWrite would exceed VFS quota.
EOPNOTSUPPOperation is not supported by the VFS.

Error objects include code, syscall, path, and message fields, matching the Node.js convention.


Files are mounted under /bundle from the function manifest. When deploying a function, include static assets in the bundle directory and they will be available at /bundle/<relative-path>.

// Read a config file shipped with the function
import { readFileSync } from "node:fs";
const config = JSON.parse(readFileSync("/bundle/config.json", "utf-8"));
--vfs-total-quota-bytes <bytes> Total writable bytes across /tmp (default: 10485760)
--vfs-max-file-bytes <bytes> Maximum size of a single file in /tmp (default: 5242880)
EDGE_RUNTIME_VFS_TOTAL_QUOTA_BYTES=10485760
EDGE_RUNTIME_VFS_MAX_FILE_BYTES=5242880

  1. Isolate creation — The VFS is initialised. /bundle is populated from the function manifest. /tmp is empty.
  2. Request handling — Code may read from /bundle and read/write to /tmp. Quota is tracked.
  3. Isolate recycle — All VFS state is discarded. No data persists across isolate lifetimes.

Because /tmp is purely in-memory and ephemeral, it should only be used for transient data such as caches or intermediate computation artifacts. Never rely on /tmp for durable storage.