Add back the patch to avoid reconnect glitch

This commit is contained in:
Valere
2026-04-03 19:08:52 +02:00
parent a89d231858
commit 9fe35ba822
2 changed files with 38 additions and 7 deletions

View File

@@ -544,13 +544,13 @@ describe("LocalTransport", () => {
}); });
}); });
it("should not update advertised transport on delayID changes, but active should update", async () => { it("should not update advertised/active transport on delayID changes, but delay Id delegation should be called", async () => {
// For simplicity, we'll just use the config livekit // For simplicity, we'll just use the config livekit
customLivekitUrl.setValue("https://lk.example.org"); customLivekitUrl.setValue("https://lk.example.org");
vi.spyOn(openIDSFU, "getSFUConfigWithOpenID").mockResolvedValue( const authCallSpy = vi
openIdResponse, .spyOn(openIDSFU, "getSFUConfigWithOpenID")
); .mockResolvedValue(openIdResponse);
const delayId$ = new BehaviorSubject<string | null>(null); const delayId$ = new BehaviorSubject<string | null>(null);
@@ -596,6 +596,7 @@ describe("LocalTransport", () => {
"https://lk.example.org", "https://lk.example.org",
); );
expect(authCallSpy).toHaveBeenCalledTimes(2);
// Now emits 3 new delays id // Now emits 3 new delays id
delayId$.next("delay_id_1"); delayId$.next("delay_id_1");
await flushPromises(); await flushPromises();
@@ -604,8 +605,24 @@ describe("LocalTransport", () => {
delayId$.next("delay_id_3"); delayId$.next("delay_id_3");
await flushPromises(); await flushPromises();
// No new emissions should've happened, it is the same transport. only auth and delegation of delay has changed // No new emissions should've happened, it is the same transport.
expect(advertisedValues.length).toEqual(1); expect(advertisedValues.length).toEqual(1);
expect(activeValues.length).toEqual(4); expect(activeValues.length).toEqual(1);
// Still we should have updated the delayID to auth
expect(authCallSpy).toHaveBeenCalledTimes(
4 * 2 /* 2 calls for each delayId ?? why */,
);
expect(authCallSpy).toHaveBeenLastCalledWith(
expect.anything(),
expect.anything(),
expect.anything(),
expect.anything(),
expect.objectContaining({
delayId: "delay_id_3",
}),
expect.anything(),
);
}); });
}); });

View File

@@ -222,7 +222,21 @@ export const createLocalTransport$ = ({
), ),
null, null,
), ),
active$: scope.behavior(preferredTransport$, null), active$: scope.behavior(
preferredTransport$.pipe(
// XXX: WORK AROUND due to a reconnection glitch.
// To remove when we have a proper way to refresh the delegation event ID without refreshing
// the whole credentials.
// We deliberately hide any changes to the SFU config because we
// do not want the app to reconnect whenever the JWT
// token changes due to us delegating a new delayed event. The
// initial SFU config for the transport is all the app needs.
distinctUntilChanged((prev, next) =>
areLivekitTransportsEqual(prev.transport, next.transport),
),
),
null,
),
}; };
}; };