Skip to content

forward worker logs to main thread - #2078

Open
lukasIO wants to merge 7 commits into
mainfrom
lukas/forward-worker-logs
Open

forward worker logs to main thread#2078
lukasIO wants to merge 7 commits into
mainfrom
lukas/forward-worker-logs

Conversation

@lukasIO

@lukasIO lukasIO commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

this allows setLogExtension (and thus external log sinks) to capture the e2ee worker logs.

@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bbf1598

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 110.97 KB (+0.08% 🔺)
dist/livekit-client.umd.js 120.14 KB (+0.08% 🔺)

@lukasIO
lukasIO marked this pull request as ready for review September 1, 2026 17:58
devin-ai-integration[bot]

This comment was marked as resolved.

@1egoman 1egoman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally makes sense, though I think my comments are worth considering prior to merging.

Comment thread src/e2ee/worker/e2ee.worker.ts
Comment thread src/e2ee/worker/e2ee.worker.ts

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

Devin Review found 1 new potential issue.

Devin Review

Comment thread src/e2ee/E2eeManager.ts
Comment on lines +132 to +134
onWorkerLogLevelChanged((level) => {
this.worker?.postMessage({ kind: 'setLogLevel', data: { level } });
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Discarded encrypted rooms remain retained

Each setup adds a global log-level listener that permanently captures the manager, worker, and room. Recreating encrypted rooms accumulates retained rooms and redundant worker messages.

Prompt for agents
E2EEManager.setup registers an onWorkerLogLevelChanged callback and ignores the returned unsubscribe function. Because logger.ts stores callbacks in a module-global Set, that callback strongly retains the E2EEManager, its Room, and its Worker after the room is discarded. Reusing the manager with another Room also installs duplicate callbacks for the same worker. Add explicit listener ownership and lifecycle cleanup: retain the unsubscribe function, avoid duplicate registration, and invoke it when the manager/room is disposed or replaced. If E2EEManager currently has no teardown lifecycle, introduce one and call it from Room cleanup while preserving log-level propagation for active workers.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in #2079

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@lukasIO
lukasIO force-pushed the lukas/forward-worker-logs branch 2 times, most recently from 5037c68 to bbf1598 Compare September 3, 2026 11:38

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Devin Review

Comment thread src/e2ee/E2eeManager.ts
break;
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Encryption failures bypass log sinks

When CryptorEvent.Error lacks a worker log, the failure only reaches event listeners. Invalid-key and unknown-state errors bypass configured log sinks.

Prompt for agents
Some FrameCryptor error paths call emitThrottledError without first invoking workerLogger, including invalid-key decryption failures and unknown encryption state. E2EEManager.onWorkerMessage no longer logs error messages, so these errors only produce EncryptionError events and never reach console output or setLogExtension. Avoid duplicate logging while preserving coverage by either logging every CryptorEvent.Error at its worker source or marking error messages that have already been logged and retaining a manager-side fallback.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

export class ErrorRateLimiter {
private lastAt: Map<string, number> = new Map();

private counts: Map<string, number> = new Map();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Do you need to have some way to clear keys in this map before .reset() is called? Is it possible that this map could become increasingly large across a long single room connection where there are a ton of diverse FrameCryptor errors? Or maybe that's low enough probability where it's most likely going to be fine. If you did want to add something here, maybe some sort of fairly long TTL for each key could be worthwhile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants