Skip to content

Auto-save Editor Overwrites File With Empty Content (Race Condition) #39

@kelvinzer0

Description

@kelvinzer0

Is there an existing issue for this?

  • I have searched the existing issues and didn't find mine.

Steps to reproduce

Summary

When typing in the editor with auto-save enabled, a race condition occurs that causes the file's previous content to be overwritten with an empty file. This issue happens more frequently when working on projects with multiple files. As a result, previously written code suddenly disappears and is replaced by an empty file.

Steps to Reproduce

  1. Open Maestro Mobile on Windows 10 (64-bit).
  2. Create or open a project containing multiple files.
  3. Open one file in the code editor.
  4. Type several lines quickly.
  5. Auto-save triggers.
  6. Switch to another file or continue typing.
  7. Randomly, the file content becomes empty after an auto-save event.

Suspected Root Cause

  • Race condition in the auto-save handler.
  • The write operation may occur before the editor finishes updating its internal buffer.
  • Multiple auto-save events might be firing in parallel.

Temporary Workaround

To prevent data loss while waiting for a fix, disable auto-save:

  • Turn off auto-save in the editor settings.
  • Save files manually (Ctrl + S) until the race condition is resolved.

Additional Notes

  • Issue occurs more often during fast typing or when switching between multiple files.
  • Likely related to asynchronous save queue or debounce mechanism.

Actual results

Actual Behavior

  • Auto-save performs an overwrite with an empty payload.
  • File content becomes empty.
  • There appears to be a race condition between the editor’s "edit" event and the auto-save write operation.

Expected results

Expected Behavior

  • Auto-save should save only the latest valid editor content.
  • It should never overwrite a file with empty data.
  • Editor event synchronization should be atomic.

About app

https://maestro.dev/#maestro-studio

About environment

Environment:

  • Maestro Mobile
  • Windows 10 64-bit
  • Multi-file project

Logs

Logs
<!-- Replace this line with your logs. *DO NOT* remove the backticks! -->

Maestro version

0.8.12

How did you install Maestro?

other (please specify in the text area below)

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions