Skip to content

armgit / Piik

Public Imported from GitHub
0

Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。

fix(route): return exact route terminal owners (#282)

AAAefe3f8d6be17
diff --git a/src/server/hybrid-media-router.ts b/src/server/hybrid-media-router.ts
index 31119ad5..5c7a8f03 100644
--- a/src/server/hybrid-media-router.ts
+++ b/src/server/hybrid-media-router.ts
@@ -486,7 +486,7 @@ export class HybridMediaRouter {
participant: this.debugPeer(participant.roomId, participant.peerId),
revision: message.revision,
accepted: settled.accepted,
- exhausted: settled.exhausted === true,
+ exhausted: settled.failedPeerIds.length > 0,
});
this.releaseResources(settled.released);
if (settled.accepted) {
@@ -498,14 +498,11 @@ export class HybridMediaRouter {
);
}
if (controller.snapshot().revision !== before) this.broadcastActive(participant.roomId, room);
- if (settled.exhausted) {
- this.sendViewerRouteStatus(participant.roomId, participant.peerId, {
- type: "route-status",
- revision: controller.snapshot().revision,
- state: "failed",
- reason: "route-exhausted",
- });
- }
+ this.sendRouteFailures(
+ participant.roomId,
+ settled.failedPeerIds,
+ controller.snapshot().revision,
+ );
this.requestPump(participant.roomId);
}
@@ -545,14 +542,11 @@ export class HybridMediaRouter {
if (controller.snapshot().revision !== before) {
this.broadcastActive(participant.roomId, room);
}
- if (progressed.exhausted) {
- this.sendViewerRouteStatus(participant.roomId, operation.demandPeerId, {
- type: "route-status",
- revision: controller.snapshot().revision,
- state: "failed",
- reason: "route-exhausted",
- });
- }
+ this.sendRouteFailures(
+ participant.roomId,
+ progressed.failedPeerIds,
+ controller.snapshot().revision,
+ );
const after = controller.snapshot().operation;
if (!progressed.accepted || after?.wakeAtMs !== operation.wakeAtMs) {
this.requestPump(participant.roomId);
@@ -640,18 +634,11 @@ export class HybridMediaRouter {
);
this.releaseResources(settled.released);
if (controller.snapshot().revision !== before) this.broadcastActive(participant.roomId, room);
- if (settled.exhausted) {
- this.sendViewerRouteStatus(
- participant.roomId,
- operation.demandPeerId,
- {
- type: "route-status",
- revision: controller.snapshot().revision,
- state: "failed",
- reason: "route-exhausted",
- },
- );
- }
+ this.sendRouteFailures(
+ participant.roomId,
+ settled.failedPeerIds,
+ controller.snapshot().revision,
+ );
this.requestPump(participant.roomId);
return;
}
@@ -815,14 +802,11 @@ export class HybridMediaRouter {
const reconciled = controller.reconcile(this.now());
this.releaseResources(reconciled.released);
if (controller.snapshot().revision !== beforeRevision) this.broadcastActive(roomId, room);
- for (const peerId of reconciled.failedPeerIds) {
- this.sendViewerRouteStatus(roomId, peerId, {
- type: "route-status",
- revision: controller.snapshot().revision,
- state: "failed",
- reason: "route-exhausted",
- });
- }
+ this.sendRouteFailures(
+ roomId,
+ reconciled.failedPeerIds,
+ controller.snapshot().revision,
+ );
const operation = reconciled.operation ?? controller.snapshot().operation;
if (!operation) {
this.clearDeadline(room);
@@ -884,14 +868,11 @@ export class HybridMediaRouter {
preparation.rejectionBucket,
);
this.releaseResources(skipped.released);
- if (skipped.exhausted) {
- this.sendViewerRouteStatus(roomId, operation.demandPeerId, {
- type: "route-status",
- revision: controller.snapshot().revision,
- state: "failed",
- reason: "route-exhausted",
- });
- }
+ this.sendRouteFailures(
+ roomId,
+ skipped.failedPeerIds,
+ controller.snapshot().revision,
+ );
continue;
}
this.resourceWaiters.delete(roomId);
@@ -905,14 +886,11 @@ export class HybridMediaRouter {
const beforeGap = controller.snapshot().revision;
const gap = controller.retireCurrentCandidateProducer(guard, this.now());
this.releaseResources(gap.released);
- if (gap.exhausted) {
- this.sendViewerRouteStatus(roomId, operation.demandPeerId, {
- type: "route-status",
- revision: controller.snapshot().revision,
- state: "failed",
- reason: "route-exhausted",
- });
- }
+ this.sendRouteFailures(
+ roomId,
+ gap.failedPeerIds,
+ controller.snapshot().revision,
+ );
if (!gap.accepted) {
this.releaseReservation(preparation.prepared.reservation);
continue;
@@ -938,18 +916,15 @@ export class HybridMediaRouter {
child: this.debugPeer(roomId, operation.childPeerId),
route: this.debugTuple(roomId, plan.tuple),
accepted: begun.accepted,
- exhausted: begun.exhausted === true,
+ exhausted: begun.failedPeerIds.length > 0,
});
this.releaseResources(begun.released);
if (!begun.accepted || !begun.operation?.current) {
- if (begun.exhausted) {
- this.sendViewerRouteStatus(roomId, operation.demandPeerId, {
- type: "route-status",
- revision: controller.snapshot().revision,
- state: "failed",
- reason: "route-exhausted",
- });
- }
+ this.sendRouteFailures(
+ roomId,
+ begun.failedPeerIds,
+ controller.snapshot().revision,
+ );
continue;
}
this.sendPrepareMessages(
@@ -1508,18 +1483,15 @@ export class HybridMediaRouter {
this.debug(roomId, "deadline-fired", {
child: this.debugPeer(roomId, operation.childPeerId),
accepted: expired.accepted,
- exhausted: expired.exhausted === true,
+ exhausted: expired.failedPeerIds.length > 0,
});
this.releaseResources(expired.released);
if (room.controller.snapshot().revision !== before) this.broadcastActive(roomId, room);
- if (expired.exhausted) {
- this.sendViewerRouteStatus(roomId, operation.demandPeerId, {
- type: "route-status",
- revision: room.controller.snapshot().revision,
- state: "failed",
- reason: "route-exhausted",
- });
- }
+ this.sendRouteFailures(
+ roomId,
+ expired.failedPeerIds,
+ room.controller.snapshot().revision,
+ );
this.requestPump(roomId);
}, Math.max(0, operation.wakeAtMs - this.now()));
timer.unref();
@@ -1739,6 +1711,21 @@ export class HybridMediaRouter {
const viewer = this.options.roomStore.getConnectedViewer(roomId, viewerPeerId);
if (viewer) this.options.sendToSession(viewer.sessionId, message);
}
+
+ private sendRouteFailures(
+ roomId: string,
+ failedPeerIds: readonly string[],
+ revision: number,
+ ): void {
+ for (const peerId of new Set(failedPeerIds)) {
+ this.sendViewerRouteStatus(roomId, peerId, {
+ type: "route-status",
+ revision,
+ state: "failed",
+ reason: "route-exhausted",
+ });
+ }
+ }
}
function cursorGuard(
diff --git a/src/server/room-route-controller.ts b/src/server/room-route-controller.ts
index 52658483..059f4585 100644
--- a/src/server/room-route-controller.ts
+++ b/src/server/room-route-controller.ts
@@ -189,7 +189,7 @@ export interface ReconcileResult<Resource> {
export interface SettleResult<Resource> {
accepted: boolean;
- exhausted?: boolean;
+ failedPeerIds: readonly string[];
activeRevision: number;
released: readonly Resource[];
}
@@ -197,7 +197,7 @@ export interface SettleResult<Resource> {
export interface BeginResult<Resource> {
accepted: boolean;
operation?: OperationSnapshot;
- exhausted?: boolean;
+ failedPeerIds: readonly string[];
released: readonly Resource[];
}
@@ -641,9 +641,7 @@ export class RoomRouteController<Resource = unknown> {
const released: Resource[] = [];
const validation = this.validateOrAdvance(nowMs);
released.push(...validation.released);
- const failedPeerIds = validation.exhaustedChildPeerId
- ? [validation.exhaustedChildPeerId]
- : [];
+ const failedPeerIds = failedPeerIdsFrom(validation);
if (
this.operation?.reason === "direct-convergence" &&
(this.hasSfuBootstrapWork() || this.selectNextChild())
@@ -787,7 +785,7 @@ export class RoomRouteController<Resource = unknown> {
return {
accepted: false,
released: [...validation.released, ...reservationResources(input.reservation)],
- exhausted: validation.exhausted,
+ failedPeerIds: failedPeerIdsFrom(validation),
};
}
const plan = operation.candidates[operation.cursor];
@@ -795,13 +793,14 @@ export class RoomRouteController<Resource = unknown> {
return {
accepted: false,
released: [...validation.released, ...reservationResources(input.reservation)],
- exhausted: validation.exhausted,
+ failedPeerIds: failedPeerIdsFrom(validation),
};
}
if (plan.endpointTransition.kind === "bounded-gap") {
return {
accepted: false,
operation: this.operationSnapshot(),
+ failedPeerIds: failedPeerIdsFrom(validation),
released: [...validation.released, ...reservationResources(input.reservation)],
};
}
@@ -817,6 +816,7 @@ export class RoomRouteController<Resource = unknown> {
return {
accepted: false,
operation: this.operationSnapshot(),
+ failedPeerIds: failedPeerIdsFrom(validation),
released: [
...validation.released,
...reservationResources(input.reservation),
@@ -853,7 +853,12 @@ export class RoomRouteController<Resource = unknown> {
cursor: operation.cursor,
});
this.startCandidateTiming(operation.demandPeerId, input.nowMs);
- return { accepted: true, operation: this.operationSnapshot(), released: validation.released };
+ return {
+ accepted: true,
+ operation: this.operationSnapshot(),
+ failedPeerIds: failedPeerIdsFrom(validation),
+ released: validation.released,
+ };
}
noteCurrentCandidateRejection(
@@ -880,7 +885,11 @@ export class RoomRouteController<Resource = unknown> {
const validation = this.validateOrAdvance(nowMs);
const operation = this.operation;
if (!operation || operation.current || !this.cursorGuardMatches(guard, operation)) {
- return { accepted: false, released: validation.released, exhausted: validation.exhausted };
+ return {
+ accepted: false,
+ failedPeerIds: failedPeerIdsFrom(validation),
+ released: validation.released,
+ };
}
if (bucket === "candidate-failed") {
this.promoteNextDirectWithinHeadStart(operation, nowMs);
@@ -899,8 +908,8 @@ export class RoomRouteController<Resource = unknown> {
return {
operation: this.operationSnapshot(),
accepted: true,
+ failedPeerIds: failedPeerIdsFrom(validation, advanced),
released: [...validation.released, ...advanced.released],
- exhausted: advanced.exhausted,
};
}
@@ -911,11 +920,20 @@ export class RoomRouteController<Resource = unknown> {
const validation = this.validateOrAdvance(nowMs);
const operation = this.operation;
if (!operation || operation.current || !this.cursorGuardMatches(guard, operation)) {
- return { accepted: false, released: validation.released, exhausted: validation.exhausted };
+ return {
+ accepted: false,
+ failedPeerIds: failedPeerIdsFrom(validation),
+ released: validation.released,
+ };
}
const plan = operation.candidates[operation.cursor];
if (!plan || plan.endpointTransition.kind !== "bounded-gap") {
- return { accepted: false, operation: this.operationSnapshot(), released: validation.released };
+ return {
+ accepted: false,
+ operation: this.operationSnapshot(),
+ failedPeerIds: failedPeerIdsFrom(validation),
+ released: validation.released,
+ };
}
const released = [...validation.released];
const retirement = plan.endpointTransition.retire;
@@ -928,7 +946,12 @@ export class RoomRouteController<Resource = unknown> {
edge.parentSessionId !== retirement.parentSessionId ||
edge.transport !== retirement.transport ||
edge.connectionId !== retirement.connectionId) {
- return { accepted: false, operation: this.operationSnapshot(), released };
+ return {
+ accepted: false,
+ operation: this.operationSnapshot(),
+ failedPeerIds: failedPeerIdsFrom(validation),
+ released,
+ };
}
if (edge.usable) {
restoreTuple = {
@@ -944,7 +967,12 @@ export class RoomRouteController<Resource = unknown> {
publication.hostSessionId !== retirement.hostSessionId ||
publication.generation !== retirement.generation ||
publication.connectionId !== retirement.connectionId) {
- return { accepted: false, operation: this.operationSnapshot(), released };
+ return {
+ accepted: false,
+ operation: this.operationSnapshot(),
+ failedPeerIds: failedPeerIdsFrom(validation),
+ released,
+ };
}
released.push(...this.removePublicationGeneration(retirement.generation));
}
@@ -960,11 +988,16 @@ export class RoomRouteController<Resource = unknown> {
return {
accepted: true,
operation: this.operationSnapshot(),
- exhausted: advanced.exhausted,
+ failedPeerIds: failedPeerIdsFrom(validation, advanced),
released: [...released, ...advanced.released],
};
}
- return { accepted: true, operation: this.operationSnapshot(), released };
+ return {
+ accepted: true,
+ operation: this.operationSnapshot(),
+ failedPeerIds: failedPeerIdsFrom(validation),
+ released,
+ };
}
candidateReady(
@@ -976,7 +1009,12 @@ export class RoomRouteController<Resource = unknown> {
const operation = this.operation;
const attempt = operation?.current;
if (!operation || !attempt || !this.guardMatches(guard, operation, attempt)) {
- return { accepted: false, exhausted: validation.exhausted, activeRevision: this.revision, released: validation.released };
+ return {
+ accepted: false,
+ failedPeerIds: failedPeerIdsFrom(validation),
+ activeRevision: this.revision,
+ released: validation.released,
+ };
}
if (!commitReservation(attempt.reservation)) {
this.debug("candidate-commit-rejected", {
@@ -989,7 +1027,7 @@ export class RoomRouteController<Resource = unknown> {
const failed = this.validateOrAdvance(nowMs, guard);
return {
accepted: false,
- exhausted: failed.exhausted,
+ failedPeerIds: failedPeerIdsFrom(validation, failed),
activeRevision: this.revision,
released: [...validation.released, ...failed.released],
};
@@ -1021,7 +1059,12 @@ export class RoomRouteController<Resource = unknown> {
for (const childPeerId of displacedSfuChildren) {
this.ensureDemand(childPeerId, nowMs, "edge-unavailable");
}
- return { accepted: true, activeRevision: this.revision, released };
+ return {
+ accepted: true,
+ failedPeerIds: failedPeerIdsFrom(validation),
+ activeRevision: this.revision,
+ released,
+ };
}
candidateTransportConnected(
@@ -1039,7 +1082,7 @@ export class RoomRouteController<Resource = unknown> {
) {
return {
accepted: false,
- exhausted: validation.exhausted,
+ failedPeerIds: failedPeerIdsFrom(validation),
activeRevision: this.revision,
released: validation.released,
};
@@ -1052,6 +1095,7 @@ export class RoomRouteController<Resource = unknown> {
});
return {
accepted: true,
+ failedPeerIds: failedPeerIdsFrom(validation),
activeRevision: this.revision,
released: validation.released,
};
@@ -1074,9 +1118,19 @@ export class RoomRouteController<Resource = unknown> {
}
const validation = this.validateOrAdvance(nowMs, guard);
if (validation.consumedGuard) {
- return { accepted: true, exhausted: validation.exhausted, activeRevision: this.revision, released: validation.released };
+ return {
+ accepted: true,
+ failedPeerIds: failedPeerIdsFrom(validation),
+ activeRevision: this.revision,
+ released: validation.released,
+ };
}
- return { accepted: false, exhausted: validation.exhausted, activeRevision: this.revision, released: validation.released };
+ return {
+ accepted: false,
+ failedPeerIds: failedPeerIdsFrom(validation),
+ activeRevision: this.revision,
+ released: validation.released,
+ };
}
operationExpired(nowMs: number): SettleResult<Resource> {
@@ -1092,7 +1146,12 @@ export class RoomRouteController<Resource = unknown> {
this.consumeDirectContinuationCandidate(this.operation);
}
const validation = this.validateOrAdvance(nowMs);
- return { accepted: validation.expired, exhausted: validation.exhausted, activeRevision: this.revision, released: validation.released };
+ return {
+ accepted: validation.expired,
+ failedPeerIds: failedPeerIdsFrom(validation),
+ activeRevision: this.revision,
+ released: validation.released,
+ };
}
dispose(): readonly Resource[] {
@@ -2573,6 +2632,18 @@ function compareParticipant(left: Participant, right: Participant): number {
return left.joinOrder - right.joinOrder || left.peerId.localeCompare(right.peerId);
}
+function failedPeerIdsFrom(
+ ...results: ReadonlyArray<{ exhaustedChildPeerId?: string }>
+): string[] {
+ return [
+ ...new Set(
+ results.flatMap((result) =>
+ result.exhaustedChildPeerId ? [result.exhaustedChildPeerId] : [],
+ ),
+ ),
+ ];
+}
+
function stablePairRank(childPeerId: string, parentPeerId: string): number {
return createHash("sha256")
.update(childPeerId)
diff --git a/tests/hybrid-media-router.test.ts b/tests/hybrid-media-router.test.ts
index 204bb0a2..48ac5f44 100644
--- a/tests/hybrid-media-router.test.ts
+++ b/tests/hybrid-media-router.test.ts
@@ -383,6 +383,107 @@ describe("HybridMediaRouter v9 runtime", () => {
}
});
+ it("reports a late final SFU bootstrap ready only to the waiting demand", async () => {
+ vi.useFakeTimers();
+ vi.setSystemTime(0);
+ const { store, sent, router } = harness(2, true, 300);
+ try {
+ const room = await store.createRoom();
+ const host = connectHost(store, room);
+ complete(router, host);
+
+ const firstRoot = connectViewer(store, room, "late-ready-first-root");
+ complete(router, firstRoot);
+ await vi.waitFor(() =>
+ expect(preparedFor(sent, firstRoot.sessionId)?.candidate.transport).toBe(
+ "direct",
+ ),
+ );
+ const firstPrepare = preparedFor(sent, firstRoot.sessionId)!;
+ router.handleRouteReady(firstRoot, {
+ type: "route-ready",
+ revision: firstPrepare.revision,
+ phase: "prepare",
+ });
+ router.setViewerRelayCapacity(firstRoot, 2);
+
+ const secondRoot = connectViewer(store, room, "late-ready-second-root");
+ complete(router, secondRoot);
+ await vi.waitFor(() =>
+ expect(preparedFor(sent, secondRoot.sessionId)?.candidate.transport).toBe(
+ "direct",
+ ),
+ );
+ const secondPrepare = preparedFor(sent, secondRoot.sessionId)!;
+ router.handleRouteReady(secondRoot, {
+ type: "route-ready",
+ revision: secondPrepare.revision,
+ phase: "prepare",
+ });
+
+ const waiting = connectViewer(store, room, "late-ready-waiting");
+ complete(router, waiting);
+ await vi.waitFor(() =>
+ expect(preparedFor(sent, waiting.sessionId)?.candidate.transport).toBe(
+ "direct",
+ ),
+ );
+
+ await vi.advanceTimersByTimeAsync(150);
+ await vi.waitFor(() =>
+ expect(preparedFor(sent, secondRoot.sessionId)?.candidate.transport).toBe(
+ "sfu",
+ ),
+ );
+ const firstCarrier = preparedFor(sent, secondRoot.sessionId)!;
+ router.handleRouteFailed(secondRoot, {
+ type: "route-failed",
+ revision: firstCarrier.revision,
+ phase: "prepare",
+ connectionId: firstCarrier.candidate.connectionId,
+ });
+
+ await vi.waitFor(() =>
+ expect(preparedFor(sent, firstRoot.sessionId)?.candidate.transport).toBe(
+ "sfu",
+ ),
+ );
+ const finalCarrier = preparedFor(sent, firstRoot.sessionId)!;
+ vi.setSystemTime(451);
+ router.handleRouteReady(firstRoot, {
+ type: "route-ready",
+ revision: finalCarrier.revision,
+ phase: "prepare",
+ });
+
+ await vi.waitFor(() =>
+ expect(
+ sent
+ .get(waiting.sessionId)
+ ?.filter(
+ (message) =>
+ message.type === "route-status" &&
+ message.state === "failed" &&
+ message.reason === "route-exhausted",
+ ),
+ ).toHaveLength(1),
+ );
+ for (const carrier of [firstRoot, secondRoot]) {
+ expect(
+ sent
+ .get(carrier.sessionId)
+ ?.some(
+ (message) =>
+ message.type === "route-status" && message.state === "failed",
+ ),
+ ).toBe(false);
+ }
+ } finally {
+ await router.close();
+ vi.useRealTimers();
+ }
+ });
+
it("reports bounded route exhaustion without raw error text", async () => {
vi.useFakeTimers();
vi.setSystemTime(0);
diff --git a/tests/room-route-controller.test.ts b/tests/room-route-controller.test.ts
index dde49f7e..61e65816 100644
--- a/tests/room-route-controller.test.ts
+++ b/tests/room-route-controller.test.ts
@@ -278,7 +278,7 @@ describe("RoomRouteController", () => {
},
30,
),
- ).toMatchObject({ accepted: true, exhausted: true });
+ ).toMatchObject({ accepted: true, failedPeerIds: [A] });
expect(routes.routeDiagnosticSnapshot(30).children[0]).toMatchObject({
finalMs: 30,
finalRoute: "failed",
@@ -374,7 +374,7 @@ describe("RoomRouteController", () => {
const deadline = routes.snapshot().operation!.deadlineAtMs;
expect(routes.operationExpired(deadline)).toMatchObject({
accepted: true,
- exhausted: true,
+ failedPeerIds: [A],
});
expect(routes.routeDiagnosticSnapshot(deadline).children[0]).toMatchObject({
finalMs: deadline,
@@ -593,7 +593,7 @@ describe("RoomRouteController", () => {
}, 1_001);
expect(failed.accepted).toBe(true);
expect(failed.activeRevision).toBeGreaterThan(first.current!.revision);
- expect(failed.exhausted).toBeUndefined();
+ expect(failed.failedPeerIds).toEqual([]);
expect(failed.released).toEqual([]);
expect(routes.snapshot().operation).toMatchObject({
cursor: 1,
@@ -617,7 +617,7 @@ describe("RoomRouteController", () => {
revision: second.current!.revision,
connectionId: "candidate_2",
}, deadline);
- expect(lateReady).toMatchObject({ accepted: false, exhausted: true });
+ expect(lateReady).toMatchObject({ accepted: false, failedPeerIds: [A] });
expect(lateReady.released).toEqual([
"candidate_2_edge",
"candidate_2_publication",
@@ -659,7 +659,7 @@ describe("RoomRouteController", () => {
});
const directExpired = routes.operationExpired(operation.wakeAtMs);
expect(directExpired).toMatchObject({ accepted: true });
- expect(directExpired.exhausted).toBeUndefined();
+ expect(directExpired.failedPeerIds).toEqual([]);
expect(routes.snapshot().operation).toMatchObject({
deadlineAtMs: 10_000,
wakeAtMs: 10_000,
@@ -948,7 +948,7 @@ describe("RoomRouteController", () => {
childSessionId: `${A}_session`,
revision: failed.current!.revision,
connectionId: "a_direct_followup",
- }, acquisition.wakeAtMs + 5).exhausted).toBeUndefined();
+ }, acquisition.wakeAtMs + 5).failedPeerIds).toEqual([]);
expect(routes.snapshot().upstreamByViewer.get(A)).toMatchObject({
kind: "sfu",
connectionId: "a_sfu",
@@ -1109,7 +1109,7 @@ describe("RoomRouteController", () => {
});
const blocked = routes.operationExpired(operation.wakeAtMs);
expect(blocked).toMatchObject({ accepted: true });
- expect(blocked.exhausted).toBe(false);
+ expect(blocked.failedPeerIds).toEqual([]);
expect(blocked.released).toEqual([]);
expect(routes.snapshot().operation).toBeUndefined();
@@ -1138,7 +1138,7 @@ describe("RoomRouteController", () => {
childSessionId: `${C}_session`,
revision: firstCarrier.current!.revision,
connectionId: "c_bootstrap_sfu",
- }, operation.wakeAtMs + 3).exhausted).toBe(false);
+ }, operation.wakeAtMs + 3).failedPeerIds).toEqual([]);
expect(routes.snapshot().upstreamByViewer.get(C)).toMatchObject({
connectionId: "c_from_host",
usable: true,
@@ -1168,7 +1168,7 @@ describe("RoomRouteController", () => {
childSessionId: `${B}_session`,
revision: secondCarrier.current!.revision,
connectionId: "b_bootstrap_sfu",
- }, operation.wakeAtMs + 6).exhausted).toBe(true);
+ }, operation.wakeAtMs + 6).failedPeerIds).toEqual([A]);
for (const [peerId, connectionId] of [
[B, "b_from_host"],
[C, "c_from_host"],
@@ -1186,7 +1186,7 @@ describe("RoomRouteController", () => {
connectionId: "d_direct",
reservation: { kind: "direct" },
});
- expect(routes.operationExpired(nextDemand.deadlineAtMs).exhausted).toBe(true);
+ expect(routes.operationExpired(nextDemand.deadlineAtMs).failedPeerIds).toEqual([D]);
expect(routes.reconcile(nextDemand.deadlineAtMs + 1).operation).toBeUndefined();
});
@@ -1868,7 +1868,7 @@ describe("RoomRouteController", () => {
childSessionId: operation.childSessionId,
revision: prepared.current!.revision,
connectionId: "failed_sfu",
- }, 2)).toMatchObject({ accepted: true, exhausted: true });
+ }, 2)).toMatchObject({ accepted: true, failedPeerIds: [A] });
const factVersion = routes.snapshot().factVersion;
expect(routes.reconcile(3).operation).toBeUndefined();
expect(routes.setEffectiveCapacity(A, `${A}_session`, 0)).toBe(true);