[PR #5313] [MERGED] fix(dev): stop watchers after writer lease conflicts #6725

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5313
Author: @SpicyMarinara
Created: 8/20/2026
Status: ✅ Merged
Merged: 8/20/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/storage-writer-lease-dev-watch-exit


📝 Commits (3)

  • 0a6a8a0 docs: record dev watcher lease fix
  • 2716588 fix(dev): stop watcher after writer lease conflict
  • 90b1b92 test: pin watcher lease conflict cause

📊 Changes

4 files changed (+86 additions, -3 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/package.json (+1 -1)
📝 packages/server/src/index.ts (+14 -0)
📝 scripts/regressions/storage-writer-lock.regression.ts (+70 -2)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #5312

Why this change

  • Abandoned development watchers remained alive after a storage-lease conflict and retried server startup after every source edit.
  • The valid single-writer guard then reported the same StorageWriterLeaseError repeatedly even though the healthy server was behaving correctly.

What changed

  • Marked the server child launched by tsx watch with a private development-only argument.
  • When that child encounters StorageWriterLeaseError during bootstrap, it terminates its watcher supervisor so the rejected session cannot remain as a retry loop.
  • Normal and production server starts keep the existing storage protection and error behavior.
  • Added an integration regression that holds a real writer lease, starts a competing dev watcher, and verifies the watcher exits without disturbing the healthy owner.

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

Automated results:

  • pnpm check — passed.
  • pnpm regression:node -- --filter storage-writer-lock — passed.
  • pnpm regression:node -- --filter dev-launcher-process — passed.
  • git diff --check — passed.

Manual verification notes

  • Observed one healthy server retaining its original writer lease while the competing guarded watcher terminated.
  • Removed eight pre-existing orphaned default-data watcher process groups; the healthy server on port 7860 remained available.
  • Removed two isolated Playwright server processes left after the earlier UI suite teardown.

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)

The user-facing fix is recorded under CHANGELOG.md [Unreleased]. No long-form documentation or release metadata changed.

UI evidence (if applicable)

  • Not applicable; this is development-process lifecycle behavior.

Summary by CodeRabbit

  • Bug Fixes

    • Development server watchers now exit after losing the file-storage writer lease.
    • Prevents abandoned sessions from retrying indefinitely and repeatedly logging lease errors.
    • Preserves the active writer’s storage lease when another development watcher starts.
    • Improved handling of watcher shutdown failures during lease conflicts.
  • Tests

    • Added regression coverage for competing development watchers and lease ownership.

🔄 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/5313 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 8/20/2026 **Status:** ✅ Merged **Merged:** 8/20/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/storage-writer-lease-dev-watch-exit` --- ### 📝 Commits (3) - [`0a6a8a0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0a6a8a01264ecb4050856b2fc87a717ffcf565ce) docs: record dev watcher lease fix - [`2716588`](https://github.com/Pasta-Devs/Marinara-Engine/commit/27165882042cff44b5e8236a97d7aca2aa224c9b) fix(dev): stop watcher after writer lease conflict - [`90b1b92`](https://github.com/Pasta-Devs/Marinara-Engine/commit/90b1b921251d67731dd05943ea1ca24394daee6c) test: pin watcher lease conflict cause ### 📊 Changes **4 files changed** (+86 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/package.json` (+1 -1) 📝 `packages/server/src/index.ts` (+14 -0) 📝 `scripts/regressions/storage-writer-lock.regression.ts` (+70 -2) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #5312 ## Why this change - Abandoned development watchers remained alive after a storage-lease conflict and retried server startup after every source edit. - The valid single-writer guard then reported the same `StorageWriterLeaseError` repeatedly even though the healthy server was behaving correctly. ## What changed - Marked the server child launched by `tsx watch` with a private development-only argument. - When that child encounters `StorageWriterLeaseError` during bootstrap, it terminates its watcher supervisor so the rejected session cannot remain as a retry loop. - Normal and production server starts keep the existing storage protection and error behavior. - Added an integration regression that holds a real writer lease, starts a competing dev watcher, and verifies the watcher exits without disturbing the healthy owner. ## 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` Automated results: - `pnpm check` — passed. - `pnpm regression:node -- --filter storage-writer-lock` — passed. - `pnpm regression:node -- --filter dev-launcher-process` — passed. - `git diff --check` — passed. ### Manual verification notes - Observed one healthy server retaining its original writer lease while the competing guarded watcher terminated. - Removed eight pre-existing orphaned default-data watcher process groups; the healthy server on port 7860 remained available. - Removed two isolated Playwright server processes left after the earlier UI suite teardown. ## 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) The user-facing fix is recorded under `CHANGELOG.md` `[Unreleased]`. No long-form documentation or release metadata changed. ## UI evidence (if applicable) - Not applicable; this is development-process lifecycle behavior. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Development server watchers now exit after losing the file-storage writer lease. * Prevents abandoned sessions from retrying indefinitely and repeatedly logging lease errors. * Preserves the active writer’s storage lease when another development watcher starts. * Improved handling of watcher shutdown failures during lease conflicts. * **Tests** * Added regression coverage for competing development watchers and lease ownership. <!-- 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:13:05 +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#6725
No description provided.