mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +00:00
* fix(runtime): retain watcher and PTY teardown ownership * fix(runtime): restore watchers after interrupted cleanup * fix(runtime): prevent stale watcher revival * test(runtime): cover watcher shutdown ownership * test(daemon): model physical PTY exit * fix(daemon): keep shutdown terminating when disposal cannot prove exit A rejecting host.dispose() (unreapable child past its exit deadline) left the shutdown RPC without its process.nextTick(shutdown) and skipped socket cleanup in shutdown(), stranding the daemon as an unreachable orphan after the stale-daemon replacement flow unlinks its socket. Log and continue: daemon exit reparents the child to init instead of blocking on it. * fix(runtime): keep local watching alive after an idle-kill deadline miss An idle child that outlived the exit deadline set shutdownRequested on the shared desktop supervisor, which has no retire-and-replace path — every later subscribe rejected supervisor_disposed and the roots were cached unwatchable, silently ending local file watching for the session. The idle path owns zero records, so there is no double-watch hazard; the zombie keeps its capacity reservation until physical exit and the next subscribe gets a fresh child. * fix(renderer): resync replayed paired-web file watches Transparent replay removed the implicit resync the old close-and-rebuild path provided: a replayed files.watch only reports changes from its own native setup, so changes during the reconnect gap were silently lost. Deliver a conservative overflow to consumers once the replayed watch is ready, matching the overflow-after-interruption contract everywhere else. * fix(runtime): address teardown review findings * fix(runtime): retry watches after teardown deadlines * Fix PTY descendant leaks on forced teardown * Fix jitter-sensitive terminal lifecycle test
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { existsSync } from 'node:fs'
|
|
import { join } from 'node:path'
|
|
|
|
type ElectronAppPath = { getAppPath(): string; isPackaged: boolean }
|
|
|
|
function loadElectronApp(): ElectronAppPath | null {
|
|
try {
|
|
return require('electron').app ?? null
|
|
} catch {
|
|
return null
|
|
}
|
|
}
|
|
|
|
export function resolveWatcherProcessEntryPath(
|
|
appPath: string,
|
|
isPackaged: boolean,
|
|
pathExists: (candidate: string) => boolean = existsSync
|
|
): string {
|
|
// Why: ELECTRON_RUN_AS_NODE bypasses Electron's asar integration, so the
|
|
// packaged entry must be forked from app.asar.unpacked.
|
|
const basePath = isPackaged ? appPath.replace('app.asar', 'app.asar.unpacked') : appPath
|
|
const adjacentBuildEntry = join(basePath, 'parcel-watcher-process-entry.js')
|
|
// Why: electron-vite's unpackaged appPath is already out/main. Appending
|
|
// out/main again silently disables crash isolation in dev and E2E builds.
|
|
if (!isPackaged && pathExists(adjacentBuildEntry)) {
|
|
return adjacentBuildEntry
|
|
}
|
|
return join(basePath, 'out', 'main', 'parcel-watcher-process-entry.js')
|
|
}
|
|
|
|
export function resolveWatcherProcessEntryPathWithoutApp(
|
|
cwd: string,
|
|
resourcesPath: string | undefined,
|
|
pathExists: (candidate: string) => boolean = existsSync
|
|
): string {
|
|
if (resourcesPath) {
|
|
const packagedEntry = join(
|
|
resourcesPath,
|
|
'app.asar.unpacked',
|
|
'out',
|
|
'main',
|
|
'parcel-watcher-process-entry.js'
|
|
)
|
|
// Why: ELECTRON_RUN_AS_NODE exposes resourcesPath but not electron.app.
|
|
// Prefer the unpacked packaged entry without breaking dev Node fallbacks.
|
|
if (pathExists(packagedEntry)) {
|
|
return packagedEntry
|
|
}
|
|
}
|
|
return resolveWatcherProcessEntryPath(cwd, false, pathExists)
|
|
}
|
|
|
|
export function getWatcherProcessEntryPath(): string {
|
|
const app = loadElectronApp()
|
|
if (app) {
|
|
return resolveWatcherProcessEntryPath(app.getAppPath(), app.isPackaged)
|
|
}
|
|
return resolveWatcherProcessEntryPathWithoutApp(process.cwd(), process.resourcesPath)
|
|
}
|