Skip to content

File can turn into empty file in certain cases #61310

@zimbo73

Description

@zimbo73

This problem occurs on VsCode v1.27.2, v1.28.2 and the Insiders version I downloaded today (1.29.0-insider), and rolling back to v1.26.1 no longer exhibits this problem. I also tested it with extensions disabled (--disable-extensions)

I have a small application watching JavaScript source files and when I save the file in VSCode they get copied to another folder (for debugging with Chrome). This app is a C# application that simply calls System.IO.File.Copy(sourceFile, destFile, true) where sourceFile is the file I am editing in VSCode, in response to a System.IO.FileSystemWatcher notification. As far as I can tell is simply uses Read access with a Read or Delete share mode.

Having used this mechanism for more than a year successfully, since updating recently it now appears that the Sharing Violations which are probably expected in this environment have a disastrous effect in that the file becomes a blank file (perhaps a brand new file replacing the previous file). Sometimes VSCode shows an error that says:

Failed to save 'myfile.jsx': A system error occured (EBUSY: resource busy or locked, open 'full/path/to/myfile.jsx')

or

Failed to save 'myfile.jsx': The content on disk is newer. Please compare your version with the one on disk.

I can reproduce this when simply starting VSCode with no extensions (--disable-extensions) (my "code watching" app is already running) and then pressing Ctrl+S (Save) to save the unmodified file. After between 1 and 5 presses of Ctrl+S the file becomes empty.

I have attach the raw Procmon.exe capture, where I started VSCode (no extensions), and a single Ctrl+S resulted in a blank file. Note the SHARING VIOLATION which I suspect is where the problem lies.
Logfile4.zip

Please let me know if there is anything else I can provide.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions