In short.
This is a documentation page from E2B for developers who run code in E2B sandboxes and want to react to file changes. It shows how to watch a sandbox directory with files.watchDir() in JavaScript/TypeScript and files.watch_dir() in Python. Its main catch is that events are tracked asynchronously and may be delayed. Some behaviour also has caveats: non-CREATE events can be missed when many nested folders are created rapidly, and the entry-information and network-mount options need specific sandbox template versions (envd v0.6.3 and v0.6.4 or above). The page covers four things: basic watching, recursive watching, including entry information, and opting in to network filesystem mounts. The documentation examples are untested, so every statement here comes from the page text, not from test results.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage is the complete documentation page at [https://docs.e2b.dev/filesystem/watch.md]. Linked pages are excluded, including the stream connections FAQ at [https://docs.e2b.dev/faq/sandbox-lifetime.md#stream-connections] and the documentation index at [https://docs.e2b.dev/llms.txt], so their content is not described. The page has no licence text, pricing, release dates or SDK version information, so those are unknown. The documentation examples are untested; all behaviour described is as stated by the page.
The overview
What this resource is
This is one documentation page, titled Watch sandbox directory for changes, hosted at [https://docs.e2b.dev/filesystem/watch.md]. It is part of the E2B documentation set. It is not a library or a tool on its own. It explains one feature of the E2B SDK: watching a directory inside a sandbox for file system events.
The page names the JavaScript method files.watchDir() and the Python method files.watch_dir(). Both are reached through a Sandbox object (sandbox.files). The page opens with a note pointing to a documentation index at [https://docs.e2b.dev/llms.txt], which suggests the documentation is also published for machine reading. The contents of that index are not described here.
Overall assessment
The page is short but practical. It gives paired JavaScript/TypeScript and Python examples for each of its four topics. It also states several real caveats: delayed event delivery, missed events when folders are created quickly, version requirements for newer options, and unreliable events on network mounts. A developer who already uses E2B sandboxes can use it to wire up file-change handling without guessing.
It is a reference page, not a tutorial. It does not explain what E2B is, how to install the SDK, how to authenticate, or how to stop a watcher. On event types, the examples use FilesystemEventType.WRITE, and the notes explicitly name CREATE and mention remove events, but the page does not give a complete list of event types. Judging by the text alone, it is good for its stated purpose and thin on surrounding context. The behaviour it describes is untested.
Who it is for
The page is for developers who create E2B sandboxes with Sandbox.create() and need to know when files change inside them. Examples would be noticing when code running in the sandbox writes an output file, or syncing changes elsewhere. The page itself does not name use cases, so these are inferences from the feature.
Beginners need some background first. The page assumes you already have a Sandbox and know basic async JavaScript (await, callbacks) or Python. Experienced developers will find the options and caveats short and usable.
What it covers
Basic watching: watch a directory (the examples use /home/user) and receive events. In JavaScript, watchDir(dirname, callback) takes an async callback that receives each event. In Python, watch_dir(dirname) returns a handle, and handle.get_new_events() returns the events that arrived since the previous call.
Recursive watching: pass recursive: true in JavaScript, or recursive=True in Python, so that changes in subdirectories are seen as well. The example writes to a file inside a nested my-folder path.
Entry information: pass includeEntry (JavaScript) or include_entry (Python) so each event carries an entry field. The page says this holds details such as path, type and size. The examples read event.entry.path and event.entry.type. The page says entry information may be unset for remove events because the path no longer exists.
Network mounts: watching paths on NFS, CIFS, SMB or FUSE mounts is rejected by default. Pass allowNetworkMounts (JavaScript) or allow_network_mounts (Python) to opt in.
The examples show the event fields event.type and event.name. They use FilesystemEventType.WRITE. The notes also explicitly name CREATE (in the rapid folder creation caveat) and mention remove events (in the entry-information caveat). The page does not give a complete list of event types.
Using it
Requirements
You need an E2B sandbox created through the SDK (Sandbox.create() in both examples) and the e2b package, which both languages import from. The page does not give install commands, package manager names, supported runtime versions, or how to supply credentials, so those are unknown from this page.
Some options depend on the sandbox template. Including entry information needs templates with envd version v0.6.3 or above. Using includeEntry or include_entry on an older sandbox throws an error. Watching network mounts needs envd v0.6.4 or above, and the allowNetworkMounts or allow_network_mounts option throws on older sandboxes. The page does not say how to check a template's envd version or how to upgrade it.
How it works
The page describes a watcher that the SDK starts against a directory in the sandbox. Events are tracked asynchronously, so delivery may be delayed. JavaScript delivers events to a callback you supply. Python collects events on a handle and you pull them with get_new_events().
A further note says the SDK asks the sandbox for a keepalive ping every 50 seconds on every stream. Because of this, a stream normally stays open for more than an hour even when nothing is written. The page says no single connection is guaranteed that long and tells you to build your client to reconnect. It links to [https://docs.e2b.dev/faq/sandbox-lifetime.md#stream-connections] for more. That linked page is not covered here, so the reconnect details are unknown.
The page does not explain the underlying implementation, such as which operating system file notification mechanism the sandbox uses. Anything beyond the behaviour above is not established.
Setup
The page does not have a separate setup section. From its examples, the pattern is: import Sandbox (and optionally FilesystemEventType) from e2b, create a sandbox, choose a directory, start the watcher, then trigger or wait for file changes.
In JavaScript, the optional third argument is an options object, for example { recursive: true } or { includeEntry: true }, passed after dirname and the callback. In Python, the options are keyword arguments to watch_dir. Installation, API keys and account setup are not covered, so they are unknown from this page.
Worked example from the page
The basic JavaScript example creates a sandbox, sets dirname to /home/user, and calls sandbox.files.watchDir(dirname, async (event) => { ... }). Inside the callback it logs the event and, when event.type equals FilesystemEventType.WRITE, logs the name of the written file. It then writes the text hello to /home/user/my-file with sandbox.files.write.
The basic Python example calls sandbox.files.watch_dir(dirname), writes the same file, then calls handle.get_new_events() and loops over the results, printing each event and a message for WRITE events. A comment in the code says the call retrieves the latest new events since the last get_new_events() call.
For recursive watching, the page adds recursive: true (or recursive=True) and writes to a nested path. The page says that if you rapidly create new folders, such as a deeply nested path, events other than CREATE might not be emitted, and recommends creating the required folder structure in advance. These examples are untested, so their output is not verified.
Assessment & evidence
Limitations and caveats
Delivery timing: events are tracked asynchronously and may be delayed. The page recommends not collecting events or closing the watcher immediately after making a change, so a quick read-after-write may miss events.
Connection lifetime: streams usually stay open for more than an hour because of the 50-second keepalive, but nothing is guaranteed, so the client must be able to reconnect.
Rapid folder creation: when many nested folders are created quickly, events other than CREATE might not be emitted.
Remove events: entry information may be unset because the path no longer exists.
Template versions: includeEntry or include_entry needs envd v0.6.3 or above, and the network-mount option needs v0.6.4 or above. Older sandboxes throw an error.
Network mounts: events may be unreliable or not delivered at all. Changes made by another client outside the sandbox, for example another machine writing to the same share, are not passed on to the watcher. Only changes made from inside the sandbox are detected.
Gaps in the page: it does not show how to stop or close a watcher, the full list of event types, the exact fields of the entry object beyond path, type and size, error handling, or how to reconnect. The described behaviour is untested.
Reasoning behind the assessment
The assessment rests on what the page itself states. It names the methods, the options in both languages, the version requirements, and the caveats. That level of detail suggests the page is useful for implementing the feature correctly.
The page is stronger on caveats than on completeness. It is open about delayed delivery, missed events and unreliable network-mount events, which helps readers avoid wrong assumptions. It does not say how to stop a watcher. On event types, the examples use WRITE and the notes name CREATE and mention remove events, but there is no complete list. Those points are therefore not rated. Because the examples are untested, the correctness of the code samples and the stated behaviour is taken from the documentation, not verified.
Alternatives
The page does not compare itself with anything. Possible alternatives, which the page does not discuss, include reading the sandbox directory on a schedule (listing files and comparing results), or running a file-watching tool of your own as a process inside the sandbox and reading its output. This page does not establish whether those are practical in E2B or how they would compare in reliability or cost. The examples use the SDK watcher API and show no separate file-watching tool installation; additional sandbox dependencies are not established.
Evidence base
The only source is the documentation page at [https://docs.e2b.dev/filesystem/watch.md]. It contains the explanatory text, the notes quoted throughout, and eight code samples: paired JavaScript/TypeScript and Python examples for basic watching, recursive watching, entry information and network mounts. The full page text is covered; linked pages are not. The documentation examples are untested.
Access & freshness
Costs
The page gives no pricing, quota, usage-limit, billing or access-fee information, either for sandboxes and file watching or for the documentation itself. Those costs are therefore unknown from this page.
Rights and licence
The page text contains no licence text, copyright notice or reuse terms for the documentation or the code samples. The licence of the E2B SDK and the terms for reusing this documentation are therefore unknown. Redistribution permission is unknown. If you want to copy the examples beyond normal reading, check E2B's own terms.
Freshness
This description reflects the page content as of 15 November 2026. The page text shows no publication or last-updated date and no documentation or SDK version number. The only versions it mentions are the envd versions v0.6.3 and v0.6.4 as minimums for two options. Whether the page matches the latest SDK release is unknown. Because the page describes behaviour that depends on sandbox template versions, readers should compare it against the current E2B documentation before relying on it.
Suggested next steps
If you use E2B, read this page alongside the connection-lifetime FAQ it links to [https://docs.e2b.dev/faq/sandbox-lifetime.md#stream-connections], and plan for reconnecting if your watcher must run for long periods.
Before using includeEntry or allowNetworkMounts, confirm your sandbox template's envd version meets v0.6.3 or v0.6.4. The page does not say how to check it.
If you rely on recursive watching and need every event type, create nested folders in advance. Allow some delay before reading or closing a watcher after a change.
The documentation examples are untested, so try them in a throwaway sandbox first. Check E2B's own pages for pricing, SDK installation and licensing, which this page does not cover.
