WhatBrokeToday
FAQ
Today's Trends
mediumInvestigatingBunv1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4+38afee6c8

Bun fs.writeFileSync Fails to Truncate Mapped Files on Windows

  1. Investigating(current)
  2. Trending(upcoming)
  3. Workaround available(upcoming)
  4. Resolved(upcoming)

Executive summary

Bun versions 1.4.0 through 1.4.4+38afee6c8 on Windows suffer from a regression where fs.writeFileSync and fs.promises.writeFile report success but fail to remove the old tail of a file when another handle holds a mapped view of it. This impacts operations where files are mmapped, such as by Git for Windows.

No verified workaround yet

None of the linked reports describe a mitigation. Follow this incident to hear when one appears.

Official fix
Technical root cause

File writing operations report success while failing to correctly truncate files that have an active mapped view on Windows.

Evidence

1 report · 1 GitHubShow
  1. [1]
    GitHub First report
    Windows: fs.writeFileSync reports success but leaves the old tail when the file has a mapped view (regression in 1.4.0)(opens GitHub issue in a new tab)

    What version of Bun is running? 1.4.4+38afee6c8 (also reproduced on 1.4.0, 1.4.1, 1.4.2 and 1.4.3; 1.3.14 is not affected) What platform is your computer? Microsoft Windows NT 10.0.26300.0 x64 What steps can reproduce the bug? On Windows, fs.writeFileSync (and fs.promises.writeFile) report success but leave the old tail of the file in place when another handle holds a mapped view of it. Any process that maps the file triggers this, for example Git for Windows, which mmaps worktree files while…

    by arthjean 1upvotes 2comments

Timeline

  1. First report on GitHub issue

    Windows: fs.writeFileSync reports success but leaves the old tail when the file has a mapped view (regression in 1.4.0)

    Source