Failed to parse file: unexpected token when running biome write --write concurrently on the same file
0 reputation · 30 Jan 2020, 01:35 UTC
0 reputation · 30 Jan 2020, 01:35 UTC
The goal is to determine whether Biome's --write operation provides an exact‑once guarantee when multiple processes invoke it simultaneously on the same file, taking into account its idempotent retry logic for transient I/O errors.
Biome retries a write after a transient failure using an idempotent approach, but the documentation does not specify any locking or serialization mechanism for concurrent invocations. A parse error aborts without attempting a write, leaving unclear whether overlapping successful writes could interleave, duplicate content, or corrupt the file.
Does Biome rely solely on filesystem atomic rename to prevent interleaving, or does it risk corrupting the file under concurrency? What observable behavior occurs when two processes retry a write after a simulated NFS latency? Is there any guarantee that the final file content reflects only one successful write?
35275 reputation · 30 Jan 2020, 09:42 UTC
Biome does not provide an exactly‑once guarantee for concurrent biome format --write invocations on the same file. There is no cross‑process locking or serialization; each process independently reads, formats, and writes. The safety mechanism is an atomic rename (write‑to‑temporary‑file then rename), so the final file contains a complete formatted output from one process—not an interleaved byte stream.
| Confirmed (from Biome’s general design) | Likely / Version‑Sensitive |
|---|---|
| Write path uses temporary file + atomic rename on POSIX filesystems. | Exact temp‑file naming, rename behavior, and retry conditions are not fully specified in public docs and may change between versions. |
| Formatting is idempotent: formatting already‑formatted content yields the same output. | Atomicity of rename on NFS or Windows depends on filesystem configuration and mount options. |
| Parse failure aborts the write; no partial write is left behind. | Concurrent invocations with different configs or Biome versions can produce flip‑flopping content that looks like corruption. |
biome format --write loops on the same file (e.g., 100 iterations in parallel shells) and verify the file parses cleanly and matches a single sequential format run.tc or a FUSE wrapper) and log each process’s exit code and any “unexpected token” errors to confirm parse failures coincide with a concurrent writer.Treat --write as safe for idempotent convergence but not for mutual exclusion. Serialize concurrent formatting yourself (CI job ordering, a lockfile, or running Biome once over a file set rather than per‑file parallel processes).
What Biome version and filesystem (local ext4, NFS version, Windows) are you using? The exact atomicity guarantees depend on these.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.