Support the 0.1.x plugin SDK (BigBlueButton 4.0) - #18
Open
imdt-claudiop wants to merge 2 commits into
Open
Conversation
…ton 4.0) Pin the build to the SDK that BigBlueButton 4.0 currently ships (0.1.26) and widen requiredSdkVersion to ^0.1.2, so the plugin also loads on 4.0 servers running an earlier 0.1.x SDK instead of being rejected at load time. Co-Authored-By: Guilherme Leme <leme.guilherme.p@gmail.com>
Soft deleted chat messages reach the plugin with a null message body, so calling search() on it throws. The throw is caught by the client global error boundary, which unmounts the plugin: after any chat message is deleted, no further code block is highlighted for the rest of the session. Optional chaining keeps those entries out of the filter. Co-Authored-By: Guilherme Leme <leme.guilherme.p@gmail.com>
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.
Why
BigBlueButton 4.0 ships version 0.1.26 of the plugin SDK. The server compares that
version against the
requiredSdkVersiondeclared in the plugin manifest and refuses toload anything that does not match, so on a 4.0 server this plugin is rejected before its
bundle is ever fetched:
This is the
v0.1.xline, which is the one that targets the 0.1.x SDK, so this makes the plugin load and work on BigBlueButton 4.0.What changed
manifest.json:requiredSdkVersionfrom~0.0.59to^0.1.2package.jsonandpackage-lock.json:bigbluebutton-html-plugin-sdkfrom0.0.66to0.1.26src/code-highlighter/component.tsx: guard the chat message filter against a null message body, so a deleted chat message no longer kills the plugin. Details below.The plugin version itself was deliberately left alone. It is cut by the
publish-tagworkflow, which also updatespackage.jsonandpackage-lock.json, so it belongs to the release process rather than to this change.The null guard
Running the plugin on a live 4.0 server surfaced a crash that is worth fixing here, because without it the plugin does not survive a normal session.
BigBlueButton soft deletes chat messages: when a message is deleted the row stays and its body becomes NULL. The schema states it directly, in
bbb-graphql-server/bbb_schema.sql:That row reaches the plugin through
useLoadedChatMessages, and the filter calls.search()on the body with no guard:so it throws
TypeError: Cannot read properties of null (reading 'search'). The throw is caught by the client global error boundary, which unmounts the plugin. The practical effect is that after any chat message is deleted, no code block sent from that point on is highlighted, for the rest of the session. Code blocks highlighted before the delete keep their highlighting, which makes the failure easy to miss.The fix is one line:
undefined > -1is false, so a null body simply drops out of the filter. Optional chaining is already the idiom in this file, on the two lines that follow. The.search(CODE_LANGUAGE_REGEX)call in themapright below is deliberately left unguarded: it only runs on entries that already passed the filter, so the body is a string there.Pre existing upstream behaviour, not a regression from the SDK bump
This is not something the SDK bump introduced. The same unguarded line is on the upstream
v0.0.xandv0.1.xbranches, byte for byte, and the crash reproduces on both lines.It is also easy to see how it got there. The SDK types the field as non nullable, in
data-consumption/domain/chat/loaded-chat-messages/types.d.ts:so nothing in the type checker or the linter points at the null case, while the server sends NULL for every soft deleted message. Flagging that mismatch rather than folding an SDK change into this pull request.
How to test
manifest.jsonanddist/BbbPluginCodeHighlight.jsfrom a URL the BigBlueButton server can reach. They have to sit next to each other, sincejavascriptEntrypointUrlis relative.javascript. The message renders with syntax highlighting.TypeErrorand every later code block rendered unhighlighted.bbb_graphqldatabase:loadFailureReasonmust be empty for this plugin.Validation
Checked against a BigBlueButton 4.0 server built from source on
v4.0.x-developat commit 93bc4864ab, with the plugin attached per meeting and the bundle built from this branch.SDK bump:
npm ci,npx tscandnpm run lintall run clean, matching what the pull request workflows runloadFailureReasonand the client reports no page errorcode.hljswith highlight spansNull guard, same server, same scripted run before and after the change:
code.hljs= 1code.hljs= 1code.hljsstays 1code.hljs= 2The error observed before the change, thrown from the plugin bundle inside
Array.filter:npx tscandnpm run lintwere re run on the final state of this branch and both are clean.Evidence
Chat panel after deleting a message, then sending a new fenced code block. Same script, same server, only the bundle differs:
Full client for each side: before, after.
Notes
requiredSdkVersionis set to^0.1.2, so any 0.1.x SDK from 0.1.2 up is accepted. The build pins 0.1.26, the SDK that 4.0 currently ships, while the wider floor also lets the plugin load on 4.0 servers that are still on an earlier 0.1.x SDK. Caret rather than tilde because on a0.xfloor the two operators accept exactly the same versions, and caret is the one that still expresses the intended range once the SDK reaches 1.0.0; note that^0.1.2by itself does not admit a 1.0.0 SDK.Co-authored with Guilherme Leme, who created the
v0.1.xbranches for these plugins.