Skip to content

fix(5k webinar) - remove js error#4826

Open
mickelr wants to merge 7 commits intowebex:nextfrom
mickelr:fix/removeTypeError
Open

fix(5k webinar) - remove js error#4826
mickelr wants to merge 7 commits intowebex:nextfrom
mickelr:fix/removeTypeError

Conversation

@mickelr
Copy link
Copy Markdown
Contributor

@mickelr mickelr commented Apr 2, 2026

COMPLETES #< INSERT LINK TO ISSUE >

This pull request addresses

A TypeError in the Mercury WebSocket message handler (_onmessage) that occurs when processing messages without an eventType property in their data payload. In large webinar scenarios (5k+ participants), Mercury can receive WebSocket messages (e.g., subscription responses, control messages) that lack the standard data.eventType field. When this happens, _getEventHandlers(data.eventType) is called with undefined, which then throws a TypeError on eventType.split('.'). This crashes the message processing pipeline and causes a hard JS error at runtime.

by making the following changes

  • Guard in _getEventHandlers(eventType) (internal-plugin-mercury/src/mercury.js): Added an early return of [] when eventType is falsy (undefined, null, or empty string), preventing a TypeError on .split().
  • Guard in _onmessage() (internal-plugin-mercury/src/mercury.js): Added a null check before calling _getEventHandlers() — if data is missing or data.eventType is not present, the message is emitted as a generic 'event' and processing returns early instead of crashing.
  • Unit tests (internal-plugin-mercury/test/unit/spec/mercury.js): Added test coverage for:
    • _onmessage() with undefined data, missing eventType, and subscription-style responses
    • _onmessage() still correctly processes messages with a valid eventType
    • _getEventHandlers() with undefined, null, empty string, and unregistered namespace inputs
  • Reverted docs/samples/meetings.min.js: Rolled back an accidental rebuild of the sample bundle that introduced a broken version header (vundefined) and content changes unrelated to this fix.

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

  • Unit tests: Added and ran tests for _onmessage() with missing data/eventType and _getEventHandlers() with falsy inputs — all pass.
  • Regression: Verified that messages with a valid eventType (e.g., conversation.activity) still route through the normal event handler pipeline.
  • Syntax validation: Confirmed docs/samples/meetings.min.js parses cleanly after rollback (node --check passes).

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was not used (or, no additional notation is required)
  • Code was generated entirely by GAI
  • GAI was used to create a draft that was subsequently customized or modified
  • Coder created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code)
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Other - Please Specify
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

I certified that

  • I have read and followed contributing guidelines
  • I discussed changes with code owners prior to submitting this pull request
  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the documentation accordingly

Make sure to have followed the contributing guidelines before submitting.

@mickelr mickelr requested review from a team as code owners April 2, 2026 10:47
@chatgpt-codex-connector
Copy link
Copy Markdown

💡 Codex Review

https://github.com/webex/webex-js-sdk/blob/fa258a6c2de92c05be68a6a59ee0fcfa700875ca/docs/samples/meetings.min.js#L2
P1 Badge Restore valid JavaScript in meetings.min.js bundle

The updated docs/samples/meetings.min.js is syntactically invalid and will fail to load in browsers/Node (node --check docs/samples/meetings.min.js now reports SyntaxError: Unexpected token ';'), while the parent version parses cleanly. This means the sample app script is broken at runtime, so users opening the meetings sample will hit a hard JS parse error before any SDK logic can run.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@aws-amplify-us-east-2
Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-4826.d3m3l2kee0btzx.amplifyapp.com

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e807ba3c8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +1248 to +1252
mercury._onmessage(mercury.defaultSessionId, event);

// Should NOT early-return — _emit should be called via the normal flow (not the guard)
// The first call would be from the .then() block, not the early return
assert.neverCalledWith(mercury._emit, mercury.defaultSessionId, 'event', event.data);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Await _onmessage before asserting valid eventType behavior

_onmessage() processes normal events asynchronously (the event emit happens in a .then(...)), but this test calls it and immediately runs assert.neverCalledWith(...). That means the assertion executes before async emits occur, so the test can pass even if valid eventType handling regresses (including the exact call this assertion is trying to reason about). This leaves the new guard path effectively unverified for the non-early-return case.

Useful? React with 👍 / 👎.

@mickelr mickelr added validated If the pull request is validated for automation. and removed validated If the pull request is validated for automation. labels Apr 3, 2026
@mickelr mickelr added the validated If the pull request is validated for automation. label Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

validated If the pull request is validated for automation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant