Files
mommysgoodpuppy 258dae7438 Never start SteamVR, and exit with the SteamVR session by default
Overlay-type VR_Init starts SteamVR when it is not running, and the
supervisor retried it every 3 s, so quitting SteamVR (or losing the
overlay host) relaunched it indefinitely. Probe with a background-type
init, which fails instead, before the overlay init.

A release binary now runs once: when the attached session ends the server
asks for its normal shutdown through a BroadcastChannel (stageforge
swallows actor errors, and workers cannot run the host's teardown).
--openvr-reattach keeps the old keep-running behaviour; the dev server
tasks pass it.

Tested: with SteamVR off, a server made seven attach attempts without
starting it and exited cleanly; an exit request from main shut down with
code 0; the probe-then-overlay init attached to genuine Frame SteamVR
2.17.10 on DroidFrame. Exiting on a real SteamVR quit is not yet tested.

Agent: Claude Code 2.1.296; model claude-opus-5-5; thread 941be8c7-aca1-4664-b284-7cc0eed69e21
2026-10-17 15:29:32 +03:00

20 lines
795 B
TypeScript

/**
* A worker asking the server process for its normal shutdown. Actors run in
* workers and cannot run the host's teardown or call `Deno.exit` for it, and
* stageforge swallows their uncaught errors. A `BroadcastChannel` reaches the
* server's main thread from any worker in the process, on every platform.
*/
const CHANNEL = "petplay-process-exit";
export function requestProcessExit(reason: string): void {
const channel = new BroadcastChannel(CHANNEL);
channel.postMessage(reason);
channel.close();
}
/** Server side: `onRequest` runs with the reason for each request. */
export function listenForProcessExitRequests(onRequest: (reason: string) => void): void {
const channel = new BroadcastChannel(CHANNEL);
channel.onmessage = (event) => onRequest(String(event.data));
}