mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6119] Pressing Ctrl+C in the Windows launcher window kills the server outright instead of shutting it down #3397
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#3397
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Sep 13, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6119
Originally assigned to: @SpicyMarinara on GitHub.
On Windows, stopping the app with Ctrl+C in the launcher console ends the server abruptly rather than shutting it down cleanly. The console never prints "Shutdown complete", and the next start warns that your previous session "ended without shutting down" and was force-quit or lost power - even though you stopped it the normal way. Anything saved in the last fraction of a second before Ctrl+C can also be lost even though the app told you it saved.
How to reproduce (try it yourself)
This only happens on Windows. Run the same steps on macOS or Linux with
./start.shas a control - there everything works correctly.stagingat52799569cand build as usual.start.bat, or run it from acmd.exewindow. Wait until the console printsStarting Marinara Engine on http://0.0.0.0:7860and then the server's ownMarinara Engine server listeningline.Shutdown complete.start.batagain and read the first few seconds of console output.What you'll see: at step 5 there is no
Shutdown completeline. At step 6 the new session printsPrevious session (pid NNN) ended without shutting down: ... Nothing was logged, so the process was ended from outside - ... on desktop, a force-quit or power loss. See Support Diagnostics for the record.That warning appears after every ordinary Ctrl+C.What should happen: the console prints
Received SIGINT; shutting down Marinara Engineand thenShutdown complete, exits cleanly, and the next start prints no force-quit warning - exactly what happens today on macOS and Linux.Do not use the
Received SIGINT; shutting down Marinara Engineline as your test: the Windows console also sends the stop key to the server directly, so that first line often prints a millisecond before the server is killed. Only the missingShutdown completeand the next-boot warning reliably show the problem.Worth doing in the same pass, because it would make this worse: start a local model so a sidecar process is running, note its process id in Task Manager, press Ctrl+C, then check whether the sidecar is still alive and still holding its port. Nothing reaps it if the clean shutdown is skipped.
To confirm this is new: in
cmd.exe, with a throwaway data directory, runnode dist\index.jsfrompackages\serverand press Ctrl+C - you get both shutdown lines. Then runnode ..\..\scripts\run-server.mjs dist\index.jsand press Ctrl+C - you get neither. The second command is whatstart.batruns today.Where it is
At staging
52799569c:scripts/run-server.mjs:16- inside the SIGINT/SIGTERM/SIGHUP relay loop (lines 9-20):child?.kill(signal);. The 39-line file has noprocess.platform === "win32"branch. On Windows, Node ignores the signal name and terminates the process forcefully (documented in the repo's ownnode_modules/@types/node/child_process.d.ts:275-276), so the server's handler never runs.scripts/run-server.mjs:17-stopTimer = setTimeout(() => child?.kill("SIGKILL"), 10_000);- the intended ten-second grace window, dead code on Windows because line 16 already terminated the child.start.bat:406-node ../../scripts/run-server.mjs dist/index.js, the Windows entry point that introduces the supervisor. Line 393 tells the user "Press Ctrl+C to stop".packages/server/src/index.ts:90-121-shutdown()and itsprocess.on("SIGINT", ...)handler, none of which runs;index.ts:69and:74-76are the onlyprocess.once("exit", ...)hooks (sidecar cleanup and exit stamping) and neither fires.packages/server/src/db/file-backed-store.ts:326-const SAVE_DEBOUNCE_MS = 750;with the timer at:3732-3737, the window in which accepted saves are still only in memory.What's happening
On Windows, pressing Ctrl+C in a console already sends the stop event to every program attached to that console, including the server. The launcher then also calls
child.kill(signal). On Windows that is not a signal at all - Windows has no signals, so Node terminates the process immediately and forcefully. The server begins shutting down properly and is killed a moment later, before it finishes.Three things are skipped. The store never drains its debounced writes, so up to about three quarters of a second of saves the app already confirmed can be lost. The bounded-close work from #5863, which exists specifically to prevent a write-dropping abrupt end, never arms. And the exit hooks never run, so sidecar processes are not cleaned up and the session is never stamped as a deliberate exit - which is why the next start reports a force-quit. That last consequence happens every time, not just when a save is pending, and it lands in Support Diagnostics, making the session postmortem from #5506 unreliable on Windows.
The data-loss part is narrower than it sounds: measured against a live server, a save that returns success reaches disk about 450 ms later, so stopping a full second after clicking Save keeps the data. The missing clean shutdown and the false force-quit report are the parts that happen every time.
Suggested fix
The launcher should not re-send a stop that the Windows console has already delivered to the server. The narrowest correct change is to make the relay POSIX-only: on Windows, mark the supervisor as stopping, skip the
child.kill(signal)call, and wait for the child's own close event - keeping the ten-second forced-kill escalation as a backstop for a server that hangs.child.kill()can never be graceful on Windows, so if the design ever changes so the server does not share the console, the stop request has to travel some other way (a Windows console control event, or a request over stdin/IPC).Whichever shape the fix takes, it needs coverage.
scripts/regressions/server-signal-shutdown.regression.ts:80-83asserts exactly the two log lines Windows breaks, but the regression lanes run only on Linux, so the Windows path has no automated coverage at all. Adding that coverage may be a separate infrastructure task if Windows CI is not available.Context
This is a regression introduced by PR #5962, which closed #5934. Before it,
start.bat:406rannode dist/index.jsdirectly and the console Ctrl+C reached the server, which shut down gracefully;scripts/run-server.mjshas exactly one commit in its history, from that PR. It undoes the protection added in #5863 on Windows and corrupts the session postmortem from #5506. PR #5962's description flagged native Windows behaviour as a manual verification item, but no follow-up issue was opened. Unreleased on staging (latest release is v2.4.4), so no shipped build is affected yet.Two corrections to earlier notes, so nobody chases the wrong code: the writer lease does recover on the next boot, but not through
probeWriterLeaseLiveness- that returns "uncertain" on Windows atfile-backed-store.ts:1603and its liveness check is armed only for Docker-on-Linux and Termux (:2348-2351); recovery comes from the process-id check at:2457. And the skipped exit hooks, including the false force-quit report, were not part of the original write-up.The failing case could not be executed here - this machine is Linux and the defect lives in Windows-only process handling - so the cost was measured on Linux by substituting an abrupt kill, and the Windows trigger rests on Node's shipped documentation plus a recorded Windows probe. A Windows pass is required before closing.
Found by an AI-assisted sweep of merged PR #5962 against issue #5934, then re-verified against staging
52799569con 2026-09-13 as far as a Linux machine allows. Please verify on Windows before fixing.@SpicyMarinara commented on GitHub (Sep 13, 2026):
@SpicyMarinara is taking this report through the issue sweep in draft PR #6137, with Codex assisting. The affected current-code path has been checked; implementation and focused regression verification are in progress.
@SpicyMarinara commented on GitHub (Sep 13, 2026):
Fixed in #6137, now merged to staging (
e044997a2). The Windows launcher lets native console signal delivery reach the server so shutdown can finish saving.