fix(service): surface a service core that stopped for good

When the service watchdog gave up or the core vanished, the owner
monitor marked the core stopped without telling the user, and on macOS
left the system proxy on the dead mixed port (#8029).

- On SameOwnerFailure, clear the proxy through the helper while the
  session is still ours; displaced or unreachable owners still leave the
  machine-wide setting alone.
- Retain the stop as a core failure with its own message, recorded
  under the lifecycle lock and shown now or on next focus; a running
  core resets the notice dedup.
- Log each watchdog restart the service reports, since launchd discards
  the service's own log.
This commit is contained in:
wonfen
2026-09-25 00:06:59 +08:00
parent 1f140dfd3a
commit daae17a40c
24 changed files with 174 additions and 45 deletions
@@ -15,8 +15,17 @@ type NavigateFunction = (path: string, options?: any) => void
type TranslateFunction = (key: string) => string
let shownStartupError: string | null = null
// Reads can settle out of order; only the newest may act, and a reset counts as one.
let startupErrorReads = 0
let settledStartupErrorRead = 0
let shownOwnerNotice: number | null = null
/** A running core has resolved every failure shown before it. */
export const forgetShownStartupError = () => {
shownStartupError = null
settledStartupErrorRead = ++startupErrorReads
}
export const handleNoticeMessage = (
status: string,
msg: string,
@@ -39,9 +48,12 @@ export const handleNoticeMessage = (
},
'set_config::error': () => showNotice.error(msg),
'core_start::error': () => {
const read = ++startupErrorReads
void getCoreStartupError()
.then(async (error) => {
if (!error) {
.then(async (failure) => {
if (read < settledStartupErrorRead) return
settledStartupErrorRead = read
if (!failure) {
shownStartupError = null
return
}
@@ -50,11 +62,19 @@ export const handleNoticeMessage = (
window.isVisible(),
window.isMinimized(),
])
if (visible && !minimized && shownStartupError !== error) {
shownStartupError = error
const shown = `${failure.kind}:${failure.detail}`
if (
read === settledStartupErrorRead &&
visible &&
!minimized &&
shownStartupError !== shown
) {
shownStartupError = shown
showNotice.error(
'settings.feedback.errors.clash.startFailed',
error,
failure.kind === 'serviceCoreStopped'
? 'settings.feedback.errors.clash.serviceCoreStopped'
: 'settings.feedback.errors.clash.startFailed',
failure.detail,
)
}
})