Cloudflare Sandboxes Add Real-time File Watching with sandbox.watch()
Key Points
- Real-time filesystem watching via sandbox.watch() method
- Server-Sent Events stream with native inotify support
- Support for create, modify, delete, and move events
Summary
Cloudflare Sandboxes now support real-time filesystem monitoring through the new sandbox.watch() method. This feature provides Server-Sent Events streams backed by native inotify, enabling Workers to receive filesystem events (create, modify, delete, move) as they occur within containers.
Key Points
- Real-time monitoring: Watch filesystem changes with native inotify support
- Event streaming: Returns standard ReadableStream that can be proxied to browser clients or consumed server-side
- Event types: Supports
create,modify,delete, andmoveoperations with path information - Flexible filtering: Includes
recursiveoption and glob pattern filtering viaincludeparameter - Server-side consumption: Use
parseSSEStream()utility to iterate over events within Workers - Move event details: Move events include both target path and original
frompath
Usage Options
recursive: Watch subdirectories (default: false)include: Array of glob patterns for event filtering
Installation
npm i @cloudflare/sandbox@latest