mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6154] Stopping the server with Ctrl+C is reported as an error even though the shutdown is clean #3427
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#3427
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/6154
Originally assigned to: @SpicyMarinara on GitHub.
Pressing Ctrl+C to stop Marinara Engine now finishes cleanly and then prints an error anyway. The server says "Shutdown complete", and right after that the launcher says the server exited with status 130, or pnpm prints a red ELIFECYCLE failure. Nothing is actually broken, but every normal stop looks like a crash, and on Termux that fake error line is also written into the saved session log people attach to support reports.
How to reproduce (try it yourself)
Use a spare checkout and a throwaway data folder, not the copy you normally run on port 7860.
pnpm start.Server listening at http://....What you'll see: the server logs
Received SIGINT; shutting down Marinara Engineand thenShutdown complete, and immediately after that pnpm printsELIFECYCLE Command failed with exit code 130.Runningecho $?prints 130.What should happen: after
Shutdown completethe command should end quietly with status 0, because the stop succeeded.The same thing on Termux, where it is louder:
./start-termux.sh, wait forServer listening, press Ctrl+C once.tail -3 ~/.marinara-engine/logs/server-*.log.What you'll see: on screen and in that saved log,
[ERROR] Marinara Engine server exited with status 130.after a completely normal stop.What should happen: no error line on screen and none in the saved log.
To confirm it is the new wrapper and not the server: from
packages/serverrunnode dist/index.js, press Ctrl+C, andecho $?prints 0 with no error line. Runnode ../../scripts/run-server.mjs dist/index.jsinstead, press Ctrl+C, andecho $?prints 130. Only the wrapper differs.Where it is
At staging
ac14dd704:scripts/run-server.mjs:13, in the signal handler:process.exitCode = 128 + (constants.signals[signal] ?? 0);scripts/run-server.mjs:37, in the wait loop:process.exitCode ??= code;start-termux.sh:711-716(the status check and the[ERROR]echo), with the session log tee armed atstart-termux.sh:15-17and restored at:719package.json:25("start": "node scripts/run-server.mjs ..."), the pnpm surfacestart.bat:406-412(if errorlevel 1thenpause)start.sh:445(exec node ../../scripts/run-server.mjs dist/index.js, exits 130 but prints nothing)packages/server/src/index.ts:108-109: the server logsShutdown completeand exits 0scripts/regressions/server-signal-shutdown.regression.ts:111:assert.equal(await exited, 130, "The launcher should retain its signal exit code");What's happening
The launcher wrapper sets its own exit code to 128 plus the signal number (130 for Ctrl+C) the instant the signal arrives, before the server has even started shutting down. The server then shuts down gracefully and exits 0, but line 37 uses
??=, so the already-set 130 can never be lowered back to the child's 0. The wrapper therefore exits normally with status 130, and every launcher that checks the status treats that as a failure: start-termux.sh prints its[ERROR]line (and the tee is still armed, so it lands in the saved log), pnpm prints ELIFECYCLE, start.sh exits 130 silently, and start.bat would take its errorlevel branch.Suggested fix
Do not set
process.exitCodein the signal handler. Set it from the child's own close status instead: use the child's code when it exited on its own (0 after a graceful shutdown), and fall back to 128 plus the signal number only when the child was actually killed by the signal, that is when the close status is null. Then the Termux error line, the pnpm failure, and the Windows errorlevel branch all disappear on a normal stop.If you would rather keep the 128+n convention for the wrapper, the alternative is to teach the two launchers that inspect the status to treat 130 and 143 as normal stops: one condition at
start-termux.sh:714and one atstart.bat:407.Either way,
scripts/regressions/server-signal-shutdown.regression.ts:111currently pins the present behaviour by asserting the launcher exits 130, so it has to change with the fix or the lane will look like a new regression.Context
Introduced by PR #5962 ("Issue Sweep: assigned runtime, agents, and setup fixes"), which added
scripts/run-server.mjswhile fixing issue #5934 (Restart Server wedging or orphaning the replacement). #5934 never mentioned exit codes. PR #6137 did touch this file, but only the Windows kill path for issue #6119, replacingchild?.kill(signal)with a win32 guard. The exit-code line right above it is unchanged, and #6137 did not touch start-termux.sh, start.sh, start.bat, package.json, or the server. Note that #6137 slightly raises the stakes on Windows: now that the server shuts down gracefully there, start.bat's errorlevel branch would fire after a fully successful stop. The Windows half (start.bat printing "Server exited unexpectedly" and blocking onpause) was not verified here, because cmd.exe may show its own "Terminate batch job (Y/N)?" prompt first and skip that branch. Everything else above was reproduced on Linux through a real terminal. Unreleased on staging: PR #5962 landed after v2.4.4.Found by an AI-assisted sweep and re-verified against staging
ac14dd704on 2026-09-13. Please verify before fixing.@SpicyMarinara commented on GitHub (Sep 13, 2026):
Codex is addressing this report on behalf of @SpicyMarinara in draft PR #6168 as part of the requested issue sweep. I will verify the reported path against staging and preserve existing behavior outside the narrow fix.