Milestone v1 (v2.0.0): Mokosh — Session Capture #1

Merged
strategy155 merged 297 commits from gsd/phase-04-harden-clean-up-optional into main 2026-05-31 15:34:17 +00:00
Showing only changes of commit 034155bc4e - Show all commits

View File

@@ -133,7 +133,20 @@ async function getVideoBufferFromOffscreen(): Promise<VideoBufferResponse> {
return new Promise<VideoBufferResponse>((resolve) => {
const timer = setTimeout(() => {
port.onMessage.removeListener(handler);
logger.warn(`Buffer fetch timed out after ${BUFFER_FETCH_TIMEOUT_MS} ms`);
// Sweep #5 fix: surface the diagnostic when the timeout fires
// because the port was replaced by a reconnect mid-request.
// The OLD port (captured as `port`) has a dead listener; the
// offscreen will encode-and-send on the NEW port but the
// listener installed there belongs to a different
// getVideoBufferFromOffscreen call (if any). Without this
// diagnostic the operator sees a silent timeout that masquerades
// as an offscreen-side problem. With it, the SW log shows the
// reconnect timing was the proximate cause.
const portReplaced = videoPort !== port;
logger.warn(
`Buffer fetch timed out after ${BUFFER_FETCH_TIMEOUT_MS} ms`,
'port_replaced_during_fetch:', portReplaced,
);
resolve({ segments: [] });
}, BUFFER_FETCH_TIMEOUT_MS);
const handler = (msg: unknown) => {