Skip to content

Native "Save As" dialog fires from a redundant internal autosave path, alongside the working postMessage-based autosave (v2.18.1) #3883

Description

@yasirr33

What happened?

While typing in an open .docx, the native OS "Save As" file picker pops up roughly 1 second after I stop typing — interrupting the flow. Dismissing it and continuing to type brings it back again after the next pause. files.autoSave is off in my VSCode settings, so this isn't VSCode's own autosave.

Steps to reproduce

Open any .docx with SuperDoc in VSCode, type continuously, then pause. Dialog appears ~1s after each pause in typing, repeatedly

SuperDoc version

v. 2.18.1

Browser

None

Additional context

There appear to be two independent autosave mechanisms running at once:

  1. AUTO_SAVE_DELAY = 1000 (main.js ~line 320808) drives scheduleAutoSave() (~320884), triggered on every editor "update" event. After 1s idle it calls saveDocument() (~320892), which exports the doc and sends it to the extension host via vscode.postMessage({type: "update", content: ...}). The extension host (extension.js lines 129-134) writes the file directly with vscode.workspace.fs.writeFile. This path is silent and correct.

  2. Separately, the bundled editor core (Editor.save() / saveTo(), main.js ~line 239754-239768) is generic library code presumably meant for the standalone superdoc.dev web product. It calls an internal writeToPath_fn (~line 240999-241021), which tries fs.writeFileSync (Node) first, and — since a VSCode webview has no Node fs access — falls through to window.showSaveFilePicker() (the File System Access API), which is what actually produces the native OS dialog.

Both appear to fire around the same ~1s idle window, so the correct silent save (path 1) and the buggy native-dialog save (path 2) are racing each other. Path 1 already persists the file, so path 2 is redundant as well as disruptive.

Suggested fix: the VSCode extension wrapper should explicitly disable/no-op the core editor's own autosave-to-path behavior (or never call .save()/.saveTo() with a resolved sourcePath in this context) since the extension already implements its own correct save flow via postMessage.

Repro: Open any .docx with SuperDoc in VSCode, type continuously, then pause. Dialog appears ~1s after each pause in typing, repeatedly

Metadata

Metadata

Assignees

No one assigned

    Labels

    stage: triageNew issue. Needs initial assessment and classificationtype: bugSomething is broken or not working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions