Ensure roomOptions in Room.connect(...) are using the locally defined variable, NOT implicitly this.roomOptions - #1169
Merged
Merged
Conversation
1egoman
requested review from
cloudwebrtc,
hiroshihorie and
xianshijing-lk
as code owners
August 10, 2026 20:15
`connect` opened with `var roomOptions = this.roomOptions;` while a parameter of the same name was in scope. Dart permits a local to shadow a parameter — silently, with no warning and the local winning — so every `RoomOptions` a caller passed to `connect` was discarded and the Room's own options were used instead. Nothing surfaced the mismatch. The parameter is deprecated in favour of the `Room` constructor, but deprecated is not the same as inert: while it is still accepted it has to take effect. It now does, falling back to the Room's options when absent. `Engine.connect` already adopted whatever it was handed, so the value propagates from there without further changes. The local is renamed to `effectiveRoomOptions`, since restoring the parameter's visibility is the whole point and leaving two things called `roomOptions` in one scope is what caused this. Adds a regression test, and threads `connectOptions`/`roomOptions` through the E2E container so it can be exercised. Verified the test fails against the old shadowing behavior. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1egoman
force-pushed
the
connect-options-fix
branch
from
August 10, 2026 20:22
43fd61a to
f1daa2a
Compare
| }) async { | ||
| var roomOptions = this.roomOptions; | ||
| if (lkPlatformIs(PlatformType.web) && (roomOptions.networkOptions.certificatePinning?.isEnabled ?? false)) { | ||
| var effectiveRoomOptions = roomOptions ?? this.roomOptions; |
Contributor
There was a problem hiding this comment.
what is this.roomOptions ? is it a default roomOptions ? or it caches the latest roomOptions ?
Can we rename it to be more clear and less error prone ?
cloudwebrtc
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While working on #1166, I discovered this bug incidentally, so here is an isolated fix.
connect's first line isvar roomOptions = this.roomOptions;. However, a parameter of the same name (roomOptions) was in scope. After some unexpected behavior, I realized that dart permits a local to shadow a parameter (silently, with no warning and the local winning) so everyRoomOptionsa caller passed toconnectwas discarded and the Room's own options were used instead. Nothing surfaced the mismatch.The
roomOptionsparameter onconnectseems to be deprecated in favor of the parameter on theRoomconstructor, but deprecated is not the same as inert: while it is still accepted it has to take effect. It now does, falling back to the Room's options when absent.Engine.connectalready adopted whatever it was handed, so the value propagates from there without further changes.The local is renamed to
effectiveRoomOptions, since restoring the parameter's visibility is the whole point and leaving two things calledroomOptionsin one scope is what caused this.I also addeds a regression test, and threaded
connectOptions/roomOptionsthrough the E2E container so it can be exercised. I verified the test failed against the old shadowing behavior.