Skip to content

server: each hosted-project save leaves the previous version behind #521

Open

Description

@bpowers

Each save of a hosted project writes a new File document to Firestore (a full serialized project) and repoints the project at it.
The previous File is never deleted or referenced again, so a project accumulates one dead document per save.
Either delete superseded versions or keep them on purpose as history.

Why it matters

Firestore storage grows with total edit count across all hosted projects, with no bound.
File.prev_id and createFile's prevId parameter suggest a version chain, but both callers pass undefined, so the schema implies history that does not exist.

Deleting a project already handles this: deleteProjectAndFiles removes every File with that project id.
The 409 and transport-failure paths of the save handler also clean up their own new File.
Only the steady-state leak on successful saves remains.

Fix

Recommended: after the conditional project update succeeds, delete the previously referenced File (log, do not fail, if the delete fails).
This keeps one File per project; a crash between the update and the delete leaks one document, which is acceptable.

Alternative: populate prev_id and keep the last K versions, which only makes sense if a restore-previous-version feature is planned.

Pointers

  • src/server/api.ts, the POST /projects/:username/:projectName handler
  • src/server/project-creation.ts, createFile
  • src/server/models/db-firestore.ts, deleteProjectAndFiles
  • src/server/schemas/file.proto (prev_id)

Activity

  1. added
    backend
    bug
    on Jun 8, 2026
  2. changed the title [-]server: hosted-project saves leak orphaned File docs in Firestore (no version chain, no GC)[/-] [+]server: each hosted-project save leaves the previous version behind[/+] on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions