From b8196be44f689133da6eea497258634a0d184b62 Mon Sep 17 00:00:00 2001 From: CSantosM <4a.santos@gmail.com> Date: Fri, 27 Nov 2026 18:05:48 +0100 Subject: [PATCH] fix(rtc-node): stop capturing native logs nothing consumes FfiClient initializes the FFI server with captureLogs set to true, as it has since the initial commit, but no code in this SDK handles the `logs` FFI event. In capture mode the Rust logger forwards every record down to trace level, libwebrtc's dump of each data channel packet included, so a process decoded and dispatched thousands of unused events per second, and each one reached every Room's onFfiEvent and its lock. With capture off the native logger falls back to env_logger, so RUST_LOG controls the native logs again. --- .changeset/rtc-no-ffi-log-capture.md | 5 ++++ packages/livekit-rtc/src/ffi_client.test.ts | 26 +++++++++++++++++++++ packages/livekit-rtc/src/ffi_client.ts | 4 +++- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .changeset/rtc-no-ffi-log-capture.md create mode 100644 packages/livekit-rtc/src/ffi_client.test.ts diff --git a/.changeset/rtc-no-ffi-log-capture.md b/.changeset/rtc-no-ffi-log-capture.md new file mode 100644 index 00000000..e5a8b806 --- /dev/null +++ b/.changeset/rtc-no-ffi-log-capture.md @@ -0,0 +1,5 @@ +--- +'@livekit/rtc-node': patch +--- + +Stop capturing native logs: nothing consumed them, and every record down to trace level (including a libwebrtc dump of each data channel packet) was decoded and dispatched to every room. RUST_LOG now controls the native logs again. diff --git a/packages/livekit-rtc/src/ffi_client.test.ts b/packages/livekit-rtc/src/ffi_client.test.ts new file mode 100644 index 00000000..01e03b20 --- /dev/null +++ b/packages/livekit-rtc/src/ffi_client.test.ts @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2026 LiveKit, Inc. +// +// SPDX-License-Identifier: Apache-2.0 +import type * as Bindings from '@livekit/rtc-ffi-bindings'; +import { afterEach, describe, expect, it, vi } from 'vitest'; + +const { livekitInitialize } = vi.hoisted(() => ({ livekitInitialize: vi.fn() })); + +vi.mock('@livekit/rtc-ffi-bindings', async () => ({ + ...(await vi.importActual('@livekit/rtc-ffi-bindings')), + livekitInitialize, +})); + +describe('FfiClient', () => { + afterEach(() => { + globalThis._ffiClientInstance = undefined; + }); + + it('leaves native logs to the native logger instead of forwarding them as FFI events', async () => { + const { FfiClient } = await import('./ffi_client.js'); + + void FfiClient.instance; + + expect(livekitInitialize).toHaveBeenCalledWith(expect.any(Function), false, expect.any(String)); + }); +}); diff --git a/packages/livekit-rtc/src/ffi_client.ts b/packages/livekit-rtc/src/ffi_client.ts index f81ac8d8..143658dc 100644 --- a/packages/livekit-rtc/src/ffi_client.ts +++ b/packages/livekit-rtc/src/ffi_client.ts @@ -52,7 +52,9 @@ export class FfiClient extends (EventEmitter as new () => TypedEmitter