Skip to content

[3.0 port] fix(bbb-web): respond to /create before downloading pre-uploaded presentations - #24971

Merged
antobinary merged 1 commit into
bigbluebutton:v3.0.x-developfrom
ramonlsouza:bp-24931
Apr 24, 2026
Merged

antobinary merged 1 commit into
bigbluebutton:v3.0.x-developfrom
ramonlsouza:bp-24931

Conversation

@ramonlsouza

Copy link
Copy Markdown
Member

What does this PR do?

backports #24931 changes to BBB 3.0.x:

Previously, uploadDocuments() was called before respondWithConference() inside the /create handler. When the request includes a pre-uploaded presentation URL (the common case for Moodle and LTI integrations), uploadDocuments() synchronously downloads the file via PresentationUrlDownloadService.savePresentation() before returning. This download blocks the HTTP thread, delaying the XML response to the LMS by however long the download takes.

The fix swaps the call order: respondWithConference() is called first, then uploadDocuments() continues on the same thread. The meeting is already fully created and running at this point (createMeeting() has returned successfully), so the LMS receives a valid SUCCESS response immediately.

This does not break error handling because:

- The return value of uploadDocuments() was already ignored at the call site before this change.
respondWithConference() always responds with SUCCESS (null msgKey/msg); upload failures are never surfaced to the LMS HTTP response — they are communicated only as internal events to meeting room clients.

- The only invalid() call inside downloadAndProcessDocument() is inside a catch (UnsupportedEncodingException) block for URLDecoder.decode(..., "UTF-8"), which is unreachable on any JVM since UTF-8 is always available.

After this change, the /create API response time is determined solely by meeting creation and plugin manifest fetching, regardless of the size or download speed of the pre-uploaded presentation.

…entations

Previously, `uploadDocuments()` was called before `respondWithConference()`
inside the `/create` handler. When the request includes a pre-uploaded
presentation URL (the common case for Moodle and LTI integrations),
`uploadDocuments()` synchronously downloads the file via
`PresentationUrlDownloadService.savePresentation()` before returning.
This download blocks the HTTP thread, delaying the XML response to the LMS
by however long the download takes.

The fix swaps the call order: `respondWithConference()` is called first,
then `uploadDocuments()` continues on the same thread. The meeting is
already fully created and running at this point (createMeeting() has
returned successfully), so the LMS receives a valid SUCCESS response
immediately.

This does not break error handling because:
- The return value of `uploadDocuments()` was already ignored at the call
  site before this change.
- `respondWithConference()` always responds with SUCCESS (null msgKey/msg);
  upload failures are never surfaced to the LMS HTTP response — they are
  communicated only as internal events to meeting room clients.
- The only `invalid()` call inside `downloadAndProcessDocument()` is inside
  a `catch (UnsupportedEncodingException)` block for `URLDecoder.decode(...,
  "UTF-8")`, which is unreachable on any JVM since UTF-8 is always
  available.

After this change, the `/create` API response time is determined solely by
meeting creation and plugin manifest fetching, regardless
of the size or download speed of the pre-uploaded presentation.
@ramonlsouza ramonlsouza added this to the Release 3.0 milestone Apr 24, 2026
@coderabbitai

coderabbitai Bot commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

The change modifies the order of operations in the meeting creation flow. When meetingService.createMeeting(newMeeting) succeeds, the conference response is now sent immediately via respondWithConference(newMeeting, null, null) before any presentation document uploads occur. Previously, the response was sent after the uploadDocuments(...) operation completed. The old response invocation has been removed to prevent duplicate responses.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • paultrudel
  • prlanzarin
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description comprehensively explains what the PR does, why it matters, and why error handling remains sound, all directly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and specifically describes the main change: swapping the order of respondWithConference() and uploadDocuments() calls to respond immediately before downloading presentations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy`:
- Around line 230-233: After calling respondWithConference(newMeeting, null,
null) in ApiController, explicitly flush the servlet response buffer by invoking
response.flushBuffer() to ensure the XML is sent before continuing; then guard
the subsequent call to uploadDocuments(xmlModules, newMeeting, false) with a
try-catch that logs any exception locally (do not rethrow) so post-response
failures do not attempt to modify the committed response or propagate errors to
the caller. Use the existing respondWithConference and uploadDocuments symbols
when locating the code and ensure only local logging is done inside the catch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d4e1a649-56e0-4963-b2a7-2e4e0cec4524

📥 Commits

Reviewing files that changed from the base of the PR and between fcb3e62 and b2f4717.

📒 Files selected for processing (1)
  • bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy

Comment on lines 230 to 233
if (meetingService.createMeeting(newMeeting)) {
respondWithConference(newMeeting, null, null)
// See if the request came with pre-uploading of presentation.
uploadDocuments(xmlModules, newMeeting, false); //

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.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

Does Grails 5 / Spring Boot with Jakarta Servlet flush the response buffer immediately when controller render() is called, or only when the action returns?

💡 Result:

No, Grails 5 / Spring Boot with Jakarta Servlet does not flush the response buffer immediately when controller render is called. The buffer is flushed only when the action returns and the servlet container (e.g., Tomcat) processes the complete response.

Citations:


Consider explicitly flushing the response and guarding the post-response upload.

Two practical concerns worth addressing before this backport lands:

  1. Response may not actually reach the LMS early. respondWithConference() calls Grails render(...) which writes to the servlet response buffer but does not force an immediate flush. The buffer is flushed only when the controller action completes and the servlet container processes the full response. Depending on network conditions, the LMS may still see the XML response only after uploadDocuments()/savePresentation() finishes, negating the performance gain for pre-uploaded presentations. An explicit response.flushBuffer() right after respondWithConference(...) makes the early-send behavior deterministic.

  2. Exceptions from uploadDocuments() after the response is committed can corrupt the wire response. Previously, any exception escaping uploadDocuments() would surface before render, allowing Grails' error handler to cleanly produce error XML. Now the response is already committed, and Grails' default error handling attempting to render an error page on a committed response will fail noisily (and may log IllegalStateException). Since the return value is ignored, wrapping the call in a try-catch with local logging is a small, safe change.

🛠️ Suggested tweak
     if (meetingService.createMeeting(newMeeting)) {
       respondWithConference(newMeeting, null, null)
-      // See if the request came with pre-uploading of presentation.
-      uploadDocuments(xmlModules, newMeeting, false);  //
+      // Ensure the SUCCESS XML actually reaches the LMS before we start
+      // (potentially slow) pre-uploaded presentation downloads.
+      try {
+        response.flushBuffer()
+      } catch (IOException ioe) {
+        log.warn("Could not flush /create response before uploadDocuments: ${ioe.message}")
+      }
+      // See if the request came with pre-uploading of presentation.
+      try {
+        uploadDocuments(xmlModules, newMeeting, false)
+      } catch (Exception e) {
+        // Response is already committed; just log so we don't trigger a
+        // failed second render via Grails' error handler.
+        log.error("uploadDocuments failed after /create response was sent for meeting ${newMeeting.getInternalId()}", e)
+      }
     } else {

Also note: the worker thread is still blocked for the full download duration after the response is flushed. That matches the PR's stated scope, but if pre-uploaded URLs are large/slow or the Tomcat pool is tight, you may want to move uploadDocuments() onto an executor in a follow-up.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy`
around lines 230 - 233, After calling respondWithConference(newMeeting, null,
null) in ApiController, explicitly flush the servlet response buffer by invoking
response.flushBuffer() to ensure the XML is sent before continuing; then guard
the subsequent call to uploadDocuments(xmlModules, newMeeting, false) with a
try-catch that logs any exception locally (do not rethrow) so post-response
failures do not attempt to modify the committed response or propagate errors to
the caller. Use the existing respondWithConference and uploadDocuments symbols
when locating the code and ensure only local logging is done inside the catch.

@antobinary antobinary changed the title fix(bbb-web): respond to /create before downloading pre-uploaded presentations [3.0 port] fix(bbb-web): respond to /create before downloading pre-uploaded presentations Apr 24, 2026
@github-actions

Copy link
Copy Markdown

✅ Automated tests have passed!

@antobinary
antobinary merged commit 89ed552 into bigbluebutton:v3.0.x-develop Apr 24, 2026
33 checks passed
@antobinary antobinary mentioned this pull request Jul 7, 2026
10 tasks done
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