Skip to content

Conversation

@4rayaditya
Copy link

This PR improves the reliability of poll delivery in breakout rooms by enhancing room resolution logic in [mod_polls_component.lua].

  • Adds robust logging for room resolution failures, making it easier to debug issues when polls are not delivered.
  • Implements a safe fallback: if the session context is missing (as can happen in breakout rooms), the module attempts to resolve the room by matching the occupant’s JID across all rooms.
  • The fallback does not trust client-supplied room JIDs, maintaining security.
  • No changes are made to the client; this is a backend-only fix.

Fixes issue #16693

@4rayaditya
Copy link
Author

@damencho could you please take a look at this solution.

@jitsi-jenkins
Copy link

Hi, thanks for your contribution!
If you haven't already done so, could you please make sure you sign our CLA (https://jitsi.org/icla for individuals and https://jitsi.org/ccla for corporations)? We would unfortunately be unable to merge your patch unless we have that piece :(.

module:log('error', '[Polls] No room found for session context: jitsi_web_query_room=%s, jitsi_web_query_prefix=%s, stanza.from=%s, stanza.to=%s',
tostring(session.jitsi_web_query_room), tostring(session.jitsi_web_query_prefix), tostring(stanza.attr.from), tostring(stanza.attr.to));
-- Fallback: try to infer room from occupant's current room if in a breakout room context
if session.jitsi_web_query_room == nil or session.jitsi_web_query_prefix == nil then
Copy link
Member

Choose a reason for hiding this comment

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

why would these be nil, they will always be set. Do you see somewhere these to be cleared?

Copy link
Author

Choose a reason for hiding this comment

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

These variables (session.jitsi_web_query_room and session.jitsi_web_query_prefix) should indeed always be set during normal operation. However, this fallback is a defensive measure for unexpected edge cases, such as:

  • Integration with custom or third-party Prosody modules that might not set these variables correctly.
  • Rare race conditions or errors during room transitions (especially with breakout rooms).
  • Potential future changes or bugs that could cause the session context to be incomplete.

I have not found any standard code that explicitly clears these variables, but the fallback ensures that, if for any reason they are missing, the system can still attempt to resolve the room and log the issue for easier debugging. This is a safeguard to make the system more robust in production.

Copy link
Member

Choose a reason for hiding this comment

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

I don't like this approach, there are plenty of other places that these two are used, should we add it everywhere.
If someone has a bug and has cleared them or not set them that needs to be fixed.
And this will not solve the polls problem.

Copy link
Author

Choose a reason for hiding this comment

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

yeah if I think about it, my approach would be only a defensive approach instead of solving the issue. Let me find where the issue is originating from.

@4rayaditya
Copy link
Author

In fact, we could add this change so that when the fallback successfully resolves the room, it also updates the session context (jitsi_web_query_room and jitsi_web_query_prefix). This ensures future poll actions for the same session work efficiently and reliably, not just the current one.

…t rooms

- Set jitsi_web_query_room and jitsi_web_query_prefix for all occupants on every room join
- Remove defensive fallback from polls component
- Enforce LF line endings for consistency
@4rayaditya
Copy link
Author

@damencho removed the fallback option but added a proper root cause fix by updating session context on all room joins. This ensures jitsi_web_query_room and jitsi_web_query_prefix are set for every occupant in breakout rooms, resolving the polls issue without workarounds.

@damencho
Copy link
Member

I see, but I don't like this approach. I will think about it

@damencho
Copy link
Member

Maybe the way to go is adding roomjid and doing validation on it, but I need some time to look how does the signalling looks like

@4rayaditya
Copy link
Author

Maybe the way to go is adding roomjid and doing validation on it, but I need some time to look how does the signalling looks like

@damencho
roomJid is already being validated in the signaling path in all major modules.
If we want to go further, we can enforce that all signaling messages must include [roomJid] and validate it centrally.
This would make the system future-proof, as you suggested.
Still I will wait till you check the signalling out and would love to work more on your suggestions.

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.

3 participants