Repository navigation
Let the gateway be asked to exit, and record the token break - #121
Merged
Merged
Conversation
fylorn
force-pushed
the
feat/windows-shutdown
branch
2 times, most recently
from
September 23, 2026 06:18
13ac1aa to
d2d9976
Compare
… break Windows has no SIGTERM, and the desktop app has two things it must do: restart core after a configuration change, and stop core before installing an update and *wait for it to be gone* -- without that wait the new one collides with the lock the old one has not released yet. On that platform the only thing left is a hard kill, which means SQLite's WAL gets no chance to settle and in-flight requests are cut mid-response. So it is a request rather than a signal, and it is slightly better than one: it is acknowledged. The desktop app knows it was received instead of firing and guessing. Both platforms use it. A path that only runs on one platform is a path nobody exercises. The handler answers before the switch is thrown. Throwing it immediately risks the process being gone before the response is written, and what the client sees then is a reset connection -- indistinguishable from core crashing, on the one exit it asked for itself. The switch stores a request that arrives before anyone is waiting (`notify_one`, not `notify_waiters`). During the first milliseconds of startup the control plane can be answering before the main loop reaches its select, and dropping that request leaves a process that never exits. The protocol version goes to 12, which #114 should have done: a request without `Authorization: Bearer` now gets 401 for everything, `/status` included. A client written against 11 never sees the bump -- it hits the 401 first -- but that line is this protocol's change history, and "when did a credential become required" is something a reader has to be able to find. The smoke script now asks core to exit and waits for the process to be gone. That is the only end-to-end check of the chain: an HTTP request throws the switch, the main loop's select wakes, the process leaves. Unit tests can show the switch flips; they cannot show it is wired to the main loop -- and the shape of getting that wrong is a 202 and a gateway that keeps running. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
fylorn
force-pushed
the
feat/windows-shutdown
branch
from
September 23, 2026 06:25
d2d9976 to
0f35362
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Windows has no SIGTERM, and the desktop app has two things it must do: restart core after a configuration change, and stop core before installing an update and wait for it to be gone — without that wait the new instance collides with the lock the old one has not released yet (there is a comment in
supervisor.rson the lite side recording that this was measured, not guessed).On that platform the only thing left is a hard kill, which means SQLite's WAL gets no chance to settle and in-flight requests are cut mid-response.
So it is a request rather than a signal — and it is slightly better than one: it is acknowledged. The desktop app knows it was received instead of firing and guessing. Both platforms use it, because a path that only runs on one platform is a path nobody exercises.
Two details that are easy to get wrong
The handler answers before the switch is thrown. Throwing it immediately risks the process being gone before the response is written, and what the client sees then is a reset connection — indistinguishable from core crashing, on the one exit it asked for itself.
The switch stores a request that arrives before anyone is waiting (
notify_one, notnotify_waiters). During the first milliseconds of startup the control plane can be answering while the main loop has not reached its select yet, and dropping that request leaves a process that never exits. There is a test for exactly that ordering.The protocol version, which #114 should have bumped
It goes to 12. A request without
Authorization: Bearernow gets 401 for everything,/statusincluded. A client written against 11 never sees the bump — it hits the 401 first — but that line is this protocol's change history, and "when did a credential become required" is something a reader has to be able to find.Verified end to end
The smoke script now asks core to exit and waits for the process to be gone (not the socket — a wedged process can lose its socket and still be there). 55 passed, 0 failed.
That is the only end-to-end check of the chain: an HTTP request throws the switch, the main loop's select wakes, the process leaves. Unit tests can show the switch flips; they cannot show it is wired to the main loop — and the shape of getting that wrong is a 202 and a gateway that keeps running happily.
🤖 Generated with Claude Code