Skip to content

Fixed wall-clock waits on filesystem events share the watch-startup defect class #318

Description

@dean0x

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliCLI commands and optionsjavascriptPull requests that update javascript coderustPull requests that update rust codetech-debtTechnical debt

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions