Skip to content

Commit 9189e4c

Browse files
mishushakovclaude
andauthored
docs: document allowNetworkMounts option for directory watching (#255)
* docs: document allowNetworkMounts option for directory watching Add a "Watching network filesystem mounts" section to the watch docs covering the allowNetworkMounts / allow_network_mounts opt-in, the envd v0.6.4 requirement, and the caveat that changes from clients outside the sandbox are not propagated to the watcher. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs: don't highlight console.log in watch examples Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs: split envd version requirement into its own note Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e48db01 commit 9189e4c

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

docs/filesystem/watch.mdx

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Including entry information requires templates with envd version `v0.6.3` or abo
108108
</Note>
109109

110110
<CodeGroup>
111-
```js JavaScript & TypeScript highlight={8,10}
111+
```js JavaScript & TypeScript highlight={10}
112112
import { Sandbox } from 'e2b'
113113

114114
const sandbox = await Sandbox.create()
@@ -141,3 +141,52 @@ for event in events:
141141
print(event.type, event.name, event.entry.path if event.entry else None)
142142
```
143143
</CodeGroup>
144+
145+
## Watching network filesystem mounts
146+
147+
By default, watching paths on network filesystem mounts (NFS, CIFS, SMB, FUSE) is rejected. You can explicitly opt in using the parameter `allowNetworkMounts` in JavaScript and `allow_network_mounts` in Python.
148+
149+
<Note>
150+
Events on network mounts may be unreliable or not delivered at all, which is why the explicit opt-in is required.
151+
152+
Changes made by another client outside of the sandbox (for example, a different machine writing to the same network share) are **not** propagated to the watcher — only changes made from within the sandbox are detected.
153+
</Note>
154+
155+
<Note>
156+
Watching network mounts requires templates with envd version `v0.6.4` or above — using the `allowNetworkMounts` / `allow_network_mounts` option on older sandboxes will throw an error.
157+
</Note>
158+
159+
<CodeGroup>
160+
```js JavaScript & TypeScript highlight={10}
161+
import { Sandbox } from 'e2b'
162+
163+
const sandbox = await Sandbox.create()
164+
const dirname = '/mnt/nfs-share/my-dir'
165+
166+
// Start watching a directory on a network mount for changes
167+
const handle = await sandbox.files.watchDir(dirname, async (event) => {
168+
console.log(event.type, event.name)
169+
}, {
170+
allowNetworkMounts: true
171+
})
172+
173+
// Trigger file write event
174+
await sandbox.files.write(`${dirname}/my-file`, 'hello')
175+
```
176+
```python Python highlight={7,14}
177+
from e2b import Sandbox
178+
179+
sandbox = Sandbox.create()
180+
dirname = '/mnt/nfs-share/my-dir'
181+
182+
# Watch a directory on a network mount for changes
183+
handle = sandbox.files.watch_dir(dirname, allow_network_mounts=True)
184+
# Trigger file write event
185+
sandbox.files.write(f"{dirname}/my-file", "hello")
186+
187+
# Retrieve the latest new events since the last `get_new_events()` call
188+
events = handle.get_new_events()
189+
for event in events:
190+
print(event.type, event.name)
191+
```
192+
</CodeGroup>

0 commit comments

Comments
 (0)