Repository navigation
[3.0 port] fix(bbb-web): respond to /create before downloading pre-uploaded presentations - #24971
Conversation
…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.
WalkthroughThe change modifies the order of operations in the meeting creation flow. When Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy
| if (meetingService.createMeeting(newMeeting)) { | ||
| respondWithConference(newMeeting, null, null) | ||
| // See if the request came with pre-uploading of presentation. | ||
| uploadDocuments(xmlModules, newMeeting, false); // |
There was a problem hiding this comment.
🧩 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:
- 1: https://grails.apache.org/docs/5.0.0/ref/Controllers/render.html
- 2: https://grails.apache.org/docs/5.1.0/api/grails/artefact/controller/support/ResponseRenderer.html
- 3: https://stackoverflow.com/questions/43978221/how-to-force-flush-of-outputstream-writer-in-spring-boot
- 4: https://stackoverflow.com/questions/41124032/how-do-you-flush-html-in-spring-mvc
- 5: Ignore flush calls on ServletServerHttpResponse body outputstream spring-projects/spring-framework#36385
- 6: https://grails.apache.org/docs/latest/ref/Servlet%20API/response.html
- 7: https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/servletresponse
- 8: https://docs.spring.io/spring-framework/reference/6.2.17/web/webmvc/mvc-controller/ann-methods/return-types.html
Consider explicitly flushing the response and guarding the post-response upload.
Two practical concerns worth addressing before this backport lands:
-
Response may not actually reach the LMS early.
respondWithConference()calls Grailsrender(...)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 afteruploadDocuments()/savePresentation()finishes, negating the performance gain for pre-uploaded presentations. An explicitresponse.flushBuffer()right afterrespondWithConference(...)makes the early-send behavior deterministic. -
Exceptions from
uploadDocuments()after the response is committed can corrupt the wire response. Previously, any exception escapinguploadDocuments()would surface beforerender, 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 logIllegalStateException). 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.
✅ Automated tests have passed! |



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.