fix(01-review): sweep #5 surface port-replaced-during-fetch diagnostic on buffer timeout
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user