Skip to content

Conversation

@k-wasniowski
Copy link
Contributor

@k-wasniowski k-wasniowski commented Apr 8, 2025

This pull request addresses

This PR resolves an issue which causes meeting to be marked as missing remote answer, even though answer was received.
It can happen, when SDP Answer processing failed from any reason:

  • Peer Connection already closed
  • Failed to setRemoteDescription
  • etc

by making the following changes

Changes in this PR will ensure that sdpAnswerTimer will be cleared up not only in successful scenarios, but also in failure cases.

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

Tested with JS-SDK Sample app

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.

@k-wasniowski k-wasniowski requested review from a team as code owners April 8, 2025 11:57
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 8, 2025

📝 Walkthrough

Walkthrough

The pull request modifies the error handling logic in the handleRoapFailure method of the Meeting class within the @webex/plugin-meetings package. It separates the handling of Errors.SdpOfferHandlingError and Errors.SdpAnswerHandlingError into distinct conditional blocks, allowing for clearer and more modular error management. Specifically, when an Errors.SdpAnswerHandlingError occurs, it triggers a behavioral metric for peer connection failure, submits a client event for the received remote SDP, and checks if this.deferSDPAnswer is defined to clear the SDP response timer and reject the deferred promise if necessary. Additionally, the unit tests have been updated to reflect these changes. There are no alterations to the declarations of exported or public entities.

Possibly related PRs

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.31.1)
packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js
🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

yarn install v1.22.22
[1/4] Resolving packages...
warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-import-resolver-typescript > [email protected]: Glob versions prior to v9 are no longer supported
warning [email protected]: Glob versions prior to v9 are no longer supported
warning intern > [email protected]: Glob versions prior to v9 are no longer supported
warning intern > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jasmine > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > jest-cli > jest-config > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > [email protected]: Glob versions prior to v9 are no longer supported
warning mocha > [email protected]: Glob versions prior to v9 are no longer supported
warning mocha > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning [email protected]: 16.1.1
warning sinon > @sinonjs/samsam > [email protected]: This package is deprecated. Use the optional chaining (?.) operator instead.
warning wd > [email protected]: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.

(For a CapTP with native promises, see @endo/eventual-send and @endo/captp)
warning wd > archiver > [email protected]: Glob versions prior to v9 are no longer supported
warning wd > [email protected]: request has been deprecated, see request/request#3142
warning wd > archiver > archiver-utils > [email protected]: Glob versions prior to v9 are no longer supported
warning wd > request > [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
warning wd > request > [email protected]: this library is no longer supported
warning @babel/cli > [email protected]: Glob versions prior to v9 are no longer supported
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning @babel/[email protected]: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
warning @babel/polyfill > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning @babel/runtime-corejs2 > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning babel-plugin-lodash > [email protected]: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-d3883cab-9fc1-48c8-a6ba-73559879a3eb > [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning workspace-aggregator-d3883cab-9fc1-48c8-a6ba-73559879a3eb > [email protected]: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-d3883cab-9fc1-48c8-a6ba-73559879a3eb > [email protected]: 16.1.1
warning workspace-aggregator-d3883cab-9fc1-48c8-a6ba-73559879a3eb > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning workspace-aggregator-d3883cab-9fc1-48c8-a6ba-73559879a3eb > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning workspace-aggregator-d3883cab-9fc1-48c8-a6ba-73559879a3eb > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning workspace-aggregator-d3883cab-9fc1-48c8-a6ba-73559879a3eb > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning workspace-aggregator-d3883cab-9fc1-48c8-a6ba-73559879a3eb > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning workspace-aggregator-d3883cab-9fc1-48c8-a6ba-73559879a3eb > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning workspace-aggregator-d3883cab-9fc1-48c8-a6ba-73559879a3eb > @babel/[email protected]: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
[2/4] Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version "^14 || ^16 || ^17 || ^18 || ^19". Got "22.9.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (2)

8698-8701: Consider assigning a real timer ID
Storing '1234' as the timer ID can make the test scenario less realistic. Instead, you can create an actual timer via clock.setTimeout(...) and use the returned handle to confirm that the correct timer is being cleared.

Here is a possible diff to illustrate the change:

-  meeting.sdpResponseTimer = '1234';
+  meeting.sdpResponseTimer = clock.setTimeout(() => {}, 100);

Additionally, consider verifying the timer was cleared using the exact ID or variable holding that handle.


8716-8716: Enhance the assertion to verify the cleared timer
Currently, the test checks only if clearTimeout was called once. For more robust test coverage, you can also verify that the exact timer ID stored in meeting.sdpResponseTimer was cleared:

 assert.calledOnce(clearTimeoutSpy);
+assert.calledWith(clearTimeoutSpy, meeting.sdpResponseTimer);
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f7ab7e and e5d702e.

📒 Files selected for processing (2)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (1 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: AWS Amplify Console Web Preview
🔇 Additional comments (2)
packages/@webex/plugin-meetings/src/meeting/index.ts (1)

6209-6216: Good fix for resource leak prevention!

This change properly clears the SDP response timer when encountering SDP offer or answer handling errors. Without this fix, the timer could remain active even after error handling, potentially leading to unexpected behavior or memory leaks. The implementation correctly checks if the timer exists before clearing it and follows the same pattern used elsewhere in the codebase.

packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (1)

8617-8628: Correct usage of sinon fake timers
Using sinon.useFakeTimers() in beforeEach and restoring the clock in afterEach is a good practice to isolate test timers from real time. This approach helps ensure that time-dependent logic is fully controlled and predictable within your tests.

@k-wasniowski k-wasniowski added the validated If the pull request is validated for automation. label Apr 8, 2025
@aws-amplify-us-east-2
Copy link

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

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (1)

8698-8704: Consider using a more realistic timer ID
Assigning '1234' to meeting.sdpResponseTimer works for verifying that clearTimeout is called, but you might store an actual numeric handle for clarity.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e5d702e and 62480a7.

📒 Files selected for processing (2)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (2 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (3 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
packages/@webex/plugin-meetings/src/meeting/index.ts (3)
packages/@webex/plugin-meetings/src/meetings/index.ts (1)
  • error (81-83)
packages/@webex/plugin-meetings/src/metrics/index.ts (1)
  • sendBehavioralMetric (61-67)
packages/@webex/plugin-meetings/src/metrics/constants.ts (1)
  • BEHAVIORAL_METRICS (81-81)
packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (1)
packages/@webex/internal-plugin-metrics/src/metrics.js (1)
  • Metrics (37-149)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Test - Unit
  • GitHub Check: Test - Integration
  • GitHub Check: Test - Style
  • GitHub Check: Test - Browser
  • GitHub Check: AWS Amplify Console Web Preview
🔇 Additional comments (3)
packages/@webex/plugin-meetings/src/meeting/index.ts (1)

6208-6237: Looks good! Properly handles SDP answer timer cleanup on errors.

The changes properly separate the handling of SdpOfferHandlingError and SdpAnswerHandlingError into distinct conditional blocks. Now when an SdpAnswerHandlingError occurs, the code correctly clears the SDP response timer and rejects the deferred promise, preventing the meeting from being incorrectly marked as missing a remote answer.

One minor suggestion would be to pass the error to the reject call:

-    this.deferSDPAnswer.reject();
+    this.deferSDPAnswer.reject(error);

This would provide more context to the caller about why the promise was rejected.

packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (2)

8617-8617: Confirm correct usage of faked timers
You're properly setting up sinon.useFakeTimers() and restoring the clock in afterEach, which helps avoid test pollution and ensures consistent timer behavior across tests.

Also applies to: 8620-8620, 8626-8628


8719-8720: Good assertion coverage
Verifying that both meeting.deferSDPAnswer.reject and clearTimeoutSpy are called once effectively tests the error handling logic. Nicely done!

@k-wasniowski k-wasniowski merged commit 827912e into webex:next Apr 10, 2025
13 checks passed
@k-wasniowski k-wasniowski deleted the fix-clear-sdp-timer-on-processing-failure branch April 10, 2025 09:00
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.

3 participants