You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
wsd, rpc: fix shim reverse-direction race via beforeFetch hook
Under FUSE_MOUNT=shim, a write inside an exec'd process didn't
make it back to the DO unless something later triggered a fresh
push/pull cycle. The shim's disk\u2192VFS path is a 250ms poll; the
worker's post-exec pullOnce races against that poll, and on a
fast exec the pull beats the poll \u2014 fetchChanges streams the
empty pre-write state and the file stays stranded in wsd's VFS
forever (or until the next exec drives another bracket).
The push direction already had a symmetric escape hatch:
afterApply on the SyncRPC fires after a peer batch commits and
the shim flushes VFS\u2192disk before the push returns. Add the
matching beforeFetch hook in the rpc server. wsd wires it to
shim.reconcileNow(), a new public method on ShimMount that runs
the same disk\u2192VFS reconcile the poll loop runs, serialised
through the same internal mutex.
With the hook in place, fetchChanges awaits the shim's reconcile
before computing the change set, so a Workspace.pull issued
right after shell.exec sees every file the spawned process
wrote. Verified end-to-end against examples/wsd-container under
wrangler dev (FUSE_MOUNT=auto resolves to shim with no /dev/fuse):
the smoke script's step 4 now passes with SETTLE_SECONDS=0, and
the previously-stranded single-exec scenario reads back the
written file immediately.
beforeFetch is documented to fire on every fetch, including ones
that would otherwise stream zero entries \u2014 the hook is what
produces the entries in the first place. Errors are caught and
logged so a wedged shim can't take down the wire. Test coverage
mirrors the afterApply set: fires once per pull, surfaces hook-
materialised writes, swallows thrown hooks.
The example script drops its post-exec sleep now that the
contract is synchronous.
0 commit comments