[GH-ISSUE #5655] Server needs a freeze detector: an OS-frozen Termux host leaves zero log evidence #3133

Closed
opened 2026-10-21 05:59:52 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @kolacheee on GitHub (Aug 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5655

Originally assigned to: @kolacheee on GitHub.

What happens

When Android freezes a backgrounded Termux process (the cached-app freezer / vendor app-sleep), the server leaves zero log evidence: an idle server at the default warn level logs nothing, every timer simply stops firing, and after the thaw everything resumes as if nothing happened. Support threads then can't distinguish "server was frozen" from "server crashed" from "network problem" — we just diagnosed exactly this in a live report (endless "Opening chat…" until Termux was foregrounded; see also #4956, same signature).

The fix

An always-on, unref()'d ~60-second tick that compares wall-clock time against the expected interval and logger.warns with the measured gap whenever a tick arrives more than ~2× late. The sandbox protocol already implements this exact pattern for its own purposes (shouldGrantSandboxResumeGrace in packages/server/src/services/extensions/sandbox-protocol.ts ~line 45) — generalize it into a small server-wide freeze detector.

That turns every future freeze into timestamped positive proof in the session log (start-termux.sh's tee captures it), and cleanly separates freezes (gap + resume burst) from kills (log just ends) in user reports.

Why it matters now

The battery-efficiency waves (correctly) removed the ambient 2-second polling that used to keep vendor freezers from classifying Termux as dormant (PR #4643's background-tab poll, PR #4723's .env stat-poll), so freezes on aggressive devices are now reachable in normal use — and today they're invisible in every artifact users can send us.

Related: wake-lock status surfacing and client-side unreachable UX are filed separately (see cross-references).

Originally created by @kolacheee on GitHub (Aug 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5655 Originally assigned to: @kolacheee on GitHub. **What happens** When Android freezes a backgrounded Termux process (the cached-app freezer / vendor app-sleep), the server leaves **zero log evidence**: an idle server at the default `warn` level logs nothing, every timer simply stops firing, and after the thaw everything resumes as if nothing happened. Support threads then can't distinguish "server was frozen" from "server crashed" from "network problem" — we just diagnosed exactly this in a live report (endless "Opening chat…" until Termux was foregrounded; see also #4956, same signature). **The fix** An always-on, `unref()`'d ~60-second tick that compares wall-clock time against the expected interval and `logger.warn`s with the measured gap whenever a tick arrives more than ~2× late. The sandbox protocol already implements this exact pattern for its own purposes (`shouldGrantSandboxResumeGrace` in `packages/server/src/services/extensions/sandbox-protocol.ts` ~line 45) — generalize it into a small server-wide freeze detector. That turns every future freeze into timestamped positive proof in the session log (`start-termux.sh`'s tee captures it), and cleanly separates freezes (gap + resume burst) from kills (log just ends) in user reports. **Why it matters now** The battery-efficiency waves (correctly) removed the ambient 2-second polling that used to keep vendor freezers from classifying Termux as dormant (PR #4643's background-tab poll, PR #4723's `.env` stat-poll), so freezes on aggressive devices are now reachable in normal use — and today they're invisible in every artifact users can send us. Related: wake-lock status surfacing and client-side unreachable UX are filed separately (see cross-references).
Author
Owner

@kolacheee commented on GitHub (Aug 29, 2026):

Termux background-freeze follow-up family (from the 2026-08-30 triage; verdict: the battery-efficiency waves removed the ambient polling that had kept vendor freezers from classifying backgrounded Termux as dormant — see #4956 for the first field report): #5655 server freeze detector, #5656 wake-lock surfacing, #5657 client unreachable-state UX, #5658 checkVersion fetch leak, #5659 TROUBLESHOOTING corrections.

<!-- gh-comment-id:5465584062 --> @kolacheee commented on GitHub (Aug 29, 2026): Termux background-freeze follow-up family (from the 2026-08-30 triage; verdict: the battery-efficiency waves removed the ambient polling that had kept vendor freezers from classifying backgrounded Termux as dormant — see #4956 for the first field report): #5655 server freeze detector, #5656 wake-lock surfacing, #5657 client unreachable-state UX, #5658 checkVersion fetch leak, #5659 TROUBLESHOOTING corrections.
Author
Owner

@kolacheee commented on GitHub (Aug 29, 2026):

Taking this together with #5656 (kolacheee + Claude agent) on branch feat/5655-5656-freeze-observability as the freeze-observability PR; draft PR to follow.

<!-- gh-comment-id:5465599150 --> @kolacheee commented on GitHub (Aug 29, 2026): Taking this together with #5656 (kolacheee + Claude agent) on branch feat/5655-5656-freeze-observability as the freeze-observability PR; draft PR to follow.
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#3133
No description provided.