Skip to content

Ensure roomOptions in Room.connect(...) are using the locally defined variable, NOT implicitly this.roomOptions - #1169

Merged
hiroshihorie merged 1 commit into
mainfrom
connect-options-fix
Aug 11, 2026
Merged

Ensure roomOptions in Room.connect(...) are using the locally defined variable, NOT implicitly this.roomOptions#1169
hiroshihorie merged 1 commit into
mainfrom
connect-options-fix

Conversation

@1egoman

@1egoman 1egoman commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

While working on #1166, I discovered this bug incidentally, so here is an isolated fix.

connect's first line is var 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 every RoomOptions a caller passed to connect was discarded and the Room's own options were used instead. Nothing surfaced the mismatch.

The roomOptions parameter on connect seems to be deprecated in favor of the parameter on 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.

I also addeds a regression test, and threaded connectOptions/roomOptions through the E2E container so it can be exercised. I verified the test failed against the old shadowing behavior.

@1egoman 1egoman changed the title Honor the roomOptions passed to Room.connect Ensure roomOptions in Room.connect(...) are using the locally defined variable, NOT implicitly this.roomOptions Aug 10, 2026

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

`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
1egoman force-pushed the connect-options-fix branch from 43fd61a to f1daa2a Compare August 10, 2026 20:22
@1egoman 1egoman mentioned this pull request Aug 10, 2026
4 tasks
Comment thread lib/src/core/room.dart
}) async {
var roomOptions = this.roomOptions;
if (lkPlatformIs(PlatformType.web) && (roomOptions.networkOptions.certificatePinning?.isEnabled ?? false)) {
var effectiveRoomOptions = roomOptions ?? this.roomOptions;

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.

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 ?

hiroshihorie
hiroshihorie approved these changes Aug 11, 2026
@hiroshihorie
hiroshihorie merged commit f14e680 into main Aug 11, 2026
15 checks passed
@hiroshihorie
hiroshihorie deleted the connect-options-fix branch August 11, 2026 07:07
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.

4 participants