[PR #6056] [MERGED] fix(launcher): skip the storage writer lease when snapshotting data for an update #7041

Closed
opened 2026-10-23 04:16:00 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6056
Author: @Romuromylus
Created: 9/11/2026
Status: ✅ Merged
Merged: 9/11/2026
Merged by: @Romuromylus

Base: staging ← Head: fix/6046-snapshot-skip-writer-lease


📝 Commits (1)

  • 8e4bce3 fix(launcher): skip the storage writer lease when snapshotting data for an update

📊 Changes

3 files changed (+55 additions, -6 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 scripts/protect-launcher-data.mjs (+23 -6)
📝 scripts/regressions/launcher/update.regression.mjs (+31 -0)

📄 Description

Linked issue

Closes #6046

Why this change

On Termux, the launcher's startup auto-update failed before it even reached git:

[ERROR] Could not protect launcher data: Cannot copy a socket file: cp returned EINVAL (cannot copy a socket file: .../.incomplete-update-.../data/storage/.writer-lease/live.sock)
[WARN] Could not create an update snapshot. Skipping auto-update to protect your data.

snapshotLauncherData (scripts/protect-launcher-data.mjs) copies the whole data directory with fs.cp before an update so the data can be restored if the update goes wrong. Since #5389 the storage writer lease keeps a Unix socket at data/storage/.writer-lease/live.sock for liveness checks. When the previous server is still running, or ended without releasing its lease (the reporter's diagnostics show 10 sessions that ended without a shutdown), that socket is still on disk when the launcher starts, fs.cp rejects it with EINVAL, the snapshot throws, and the launcher skips the update on every launch. The .incomplete-update-* directory named in the error is removed by the snapshot's own cleanup, which is why the reporter could not find it.

What changed

  • scripts/protect-launcher-data.mjs: the snapshot copy filter now excludes data/storage/.writer-lease (per-process runtime state, not user data) and, as a general backstop, any socket or FIFO under the data directory. Everything else the snapshot copied before is unchanged, and restoreLauncherDataIfMissing is unaffected because the backup no longer contains those entries.
  • scripts/regressions/launcher/update.regression.mjs: the snapshot case now plants a writer-lease directory with an owner.json and, on non-Windows hosts, a real listening Unix socket at live.sock, and asserts the snapshot succeeds, omits the lease directory, and still preserves a sharded storage table next to it. Fails on the previous code with the exact EINVAL from the report on Linux, and on the lease-directory assertion everywhere.
  • CHANGELOG.md: Unreleased entry.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • node scripts/regressions/launcher/update.regression.mjs passes with the fix and fails against the previous protect-launcher-data.mjs on the new lease-directory assertion (pnpm regression:launcher-update is the CI lane that runs it).
  • The socket branch of the regression is exercised on Linux CI; on Windows there is no filesystem socket entry, so only the directory exclusion runs there.
  • This is launcher-only code (start.sh / start-termux.sh call the script); the Docker image never runs it, so there is nothing to observe on a container deploy.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Not applicable (launcher script).

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Termux and Linux launcher auto-updates failing with “Cannot copy a socket file” when leftover server lease data is present.
    • Launcher data snapshots now safely skip temporary lease folders and socket or FIFO files while preserving user data.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/6056 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 9/11/2026 **Status:** ✅ Merged **Merged:** 9/11/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `staging` ← **Head:** `fix/6046-snapshot-skip-writer-lease` --- ### 📝 Commits (1) - [`8e4bce3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8e4bce3fbe334f7389cb72370e96a1a8bbaad376) fix(launcher): skip the storage writer lease when snapshotting data for an update ### 📊 Changes **3 files changed** (+55 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `scripts/protect-launcher-data.mjs` (+23 -6) 📝 `scripts/regressions/launcher/update.regression.mjs` (+31 -0) </details> ### 📄 Description ## Linked issue Closes #6046 ## Why this change On Termux, the launcher's startup auto-update failed before it even reached git: ``` [ERROR] Could not protect launcher data: Cannot copy a socket file: cp returned EINVAL (cannot copy a socket file: .../.incomplete-update-.../data/storage/.writer-lease/live.sock) [WARN] Could not create an update snapshot. Skipping auto-update to protect your data. ``` `snapshotLauncherData` (`scripts/protect-launcher-data.mjs`) copies the whole data directory with `fs.cp` before an update so the data can be restored if the update goes wrong. Since #5389 the storage writer lease keeps a Unix socket at `data/storage/.writer-lease/live.sock` for liveness checks. When the previous server is still running, or ended without releasing its lease (the reporter's diagnostics show 10 sessions that ended without a shutdown), that socket is still on disk when the launcher starts, `fs.cp` rejects it with `EINVAL`, the snapshot throws, and the launcher skips the update on every launch. The `.incomplete-update-*` directory named in the error is removed by the snapshot's own cleanup, which is why the reporter could not find it. ## What changed - `scripts/protect-launcher-data.mjs`: the snapshot copy filter now excludes `data/storage/.writer-lease` (per-process runtime state, not user data) and, as a general backstop, any socket or FIFO under the data directory. Everything else the snapshot copied before is unchanged, and `restoreLauncherDataIfMissing` is unaffected because the backup no longer contains those entries. - `scripts/regressions/launcher/update.regression.mjs`: the snapshot case now plants a writer-lease directory with an `owner.json` and, on non-Windows hosts, a real listening Unix socket at `live.sock`, and asserts the snapshot succeeds, omits the lease directory, and still preserves a sharded storage table next to it. Fails on the previous code with the exact `EINVAL` from the report on Linux, and on the lease-directory assertion everywhere. - `CHANGELOG.md`: Unreleased entry. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - `node scripts/regressions/launcher/update.regression.mjs` passes with the fix and fails against the previous `protect-launcher-data.mjs` on the new lease-directory assertion (`pnpm regression:launcher-update` is the CI lane that runs it). - The socket branch of the regression is exercised on Linux CI; on Windows there is no filesystem socket entry, so only the directory exclusion runs there. - This is launcher-only code (`start.sh` / `start-termux.sh` call the script); the Docker image never runs it, so there is nothing to observe on a container deploy. ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) Not applicable (launcher script). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Fixed Termux and Linux launcher auto-updates failing with “Cannot copy a socket file” when leftover server lease data is present. - Launcher data snapshots now safely skip temporary lease folders and socket or FIFO files while preserving user data. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:16:00 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7041
No description provided.