-
Notifications
You must be signed in to change notification settings - Fork 168
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Environment
Node 22 and Unstorage 1.17.1.
Reproduction
import { createStorage } from "unstorage";
import fsDriver from "unstorage/drivers/fs";
const storage = createStorage({
driver: fsDriver({ base: "./.storage/test" }),
});
// Set up watch BEFORE the directory exists
await storage.watch((event, key) => {
console.log("Storage changed:", event, key);
});
// watch callback will NOT fire
await storage.setItem("key1", "value1");
Describe the bug
My theory:
The fs driver's watch() method uses chokidar to monitor file system changes. When watch() is called on a path that doesn't exist yet (e.g., ./.storage/test), chokidar initializes the watcher but may not properly detect the first write operation that creates the directory structure.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working