mirror of
https://github.com/stablyai/orca.git
synced 2026-10-07 08:02:21 +00:00
* refactor(daemon): split oversized PTY services * revert(daemon): restore merge-base session listing and canceled-spawn behavior Two behavior changes rode along with the file-splitting refactor: - listLiveTerminalHostSessions dropped sessions with isTerminating, not just dead ones, hiding sessions the merge base still advertised. - spawnAndPublishSession called session.beginTermination() before publishing a canceled spawn into the host map. Both hunks are reverted to the merge base; the refactor is untouched.
26 lines
785 B
TypeScript
26 lines
785 B
TypeScript
export function remainingDaemonRequestTimeoutMs(
|
|
deadlineMs: number | undefined
|
|
): number | undefined {
|
|
return deadlineMs === undefined ? undefined : Math.max(1, deadlineMs - Date.now())
|
|
}
|
|
|
|
// The caller's wait is bounded without cancelling durable work, which keeps running and committing.
|
|
export async function awaitDaemonWorkWithinCallerDeadline(
|
|
work: Promise<void>,
|
|
deadlineMs: number
|
|
): Promise<boolean> {
|
|
void work.catch(() => {})
|
|
let timer: ReturnType<typeof setTimeout> | undefined
|
|
try {
|
|
return await Promise.race([
|
|
work.then(() => true),
|
|
new Promise<boolean>((resolve) => {
|
|
timer = setTimeout(() => resolve(false), Math.max(1, deadlineMs - Date.now()))
|
|
timer.unref?.()
|
|
})
|
|
])
|
|
} finally {
|
|
clearTimeout(timer)
|
|
}
|
|
}
|