Origin: #317 (mds watch startup race — compile-before-arm ordering bug)
The same defective synchronization primitive — a fixed wall-clock deadline polling for filesystem state, used as a synchronizer rather than as a failure bound — appears in two places that were deliberately left out of the watch.rs startup-race fix to keep that change reviewable:
Affected sites
crates/mds-cli/tests/cli_build.rs
Correction (2026-08-26): there is 1 affected site, not several — cli_build.rs:1138-1148. It is a bounded content-predicate poll, not a bare sleep-then-assert anti-pattern. The residual defect is only that it does not use the MDS_TEST_READY handshake that now exists for this purpose.
packages/bundler-utils/__test__/hmr-harness.mjs
waitFor / waitForContent helpers with timeoutMs = 5000 and intervalMs = 50, consumed by 4 HMR/watch end-to-end spec files (rollup/rspack/vite/webpack *-e2e.spec.mjs). Note: most call sites override the 5000ms default anyway.
These JS HMR specs are already known-flaky. They are Linux-gated (HMR_ENABLED = process.platform === 'linux' || process.env.MDS_HMR === '1'), which matches the Linux-only signature of the watch.rs bug described in #317, and makes it worth investigating whether they share the same root cause rather than merely the same symptom.
The general principle
Waiting on a deterministic readiness signal from the process — for example, a sentinel written to stdout/stderr, a stable inode state established by the process itself before signalling completion, or a watcher armed before the first write — is the durable fix class. Polling against a wall-clock timer is an approximation that fails when the system is slower than expected and masks the defect rather than removing it.
Scope of this issue
Origin: #317 (
mds watchstartup race — compile-before-arm ordering bug)The same defective synchronization primitive — a fixed wall-clock deadline polling for filesystem state, used as a synchronizer rather than as a failure bound — appears in two places that were deliberately left out of the
watch.rsstartup-race fix to keep that change reviewable:Affected sites
crates/mds-cli/tests/cli_build.rsCorrection (2026-08-26): there is 1 affected site, not several —
cli_build.rs:1138-1148. It is a bounded content-predicate poll, not a bare sleep-then-assert anti-pattern. The residual defect is only that it does not use theMDS_TEST_READYhandshake that now exists for this purpose.packages/bundler-utils/__test__/hmr-harness.mjswaitFor/waitForContenthelpers withtimeoutMs = 5000andintervalMs = 50, consumed by 4 HMR/watch end-to-end spec files (rollup/rspack/vite/webpack*-e2e.spec.mjs). Note: most call sites override the 5000ms default anyway.These JS HMR specs are already known-flaky. They are Linux-gated (
HMR_ENABLED = process.platform === 'linux' || process.env.MDS_HMR === '1'), which matches the Linux-only signature of thewatch.rsbug described in #317, and makes it worth investigating whether they share the same root cause rather than merely the same symptom.The general principle
Waiting on a deterministic readiness signal from the process — for example, a sentinel written to stdout/stderr, a stable inode state established by the process itself before signalling completion, or a watcher armed before the first write — is the durable fix class. Polling against a wall-clock timer is an approximation that fails when the system is slower than expected and masks the defect rather than removing it.
Scope of this issue
cli_build.rsfixed-duration waits and replace with event-driven or process-signalled synchronization.hmr-harness.mjswaitFor/waitForContentcall sites; if the flakiness signature matches mds watch silently loses edits made during startup #317, apply the same fix class. If the root cause is distinct, document it separately.watch.rsitself — those are tracked in mds watch silently loses edits made during startup #317.