Skip to content

fix(mercury): handle race condition in mercury plugin to connect if u…#4672

Draft
robstax wants to merge 1 commit intowebex:nextfrom
robstax:rstachof/mercury-race-condition-fix
Draft

fix(mercury): handle race condition in mercury plugin to connect if u…#4672
robstax wants to merge 1 commit intowebex:nextfrom
robstax:rstachof/mercury-race-condition-fix

Conversation

@robstax
Copy link
Contributor

@robstax robstax commented Jan 30, 2026

…rls dont match from device

COMPLETES #< INSERT LINK TO ISSUE >

This pull request addresses

< DESCRIBE THE CONTEXT OF THE ISSUE >

by making the following changes

< DESCRIBE YOUR CHANGES >

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

< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >

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.

@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-4672.d3m3l2kee0btzx.amplifyapp.com

this.connecting = true;
this.logger.info(`${this.namespace}: reconnecting to new URL after URL mismatch`);

return this._connectWithBackoff(webSocketUrl);
Copy link
Collaborator

Choose a reason for hiding this comment

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

existing code does also this:
this.webex.internal.device.registered || this.webex.internal.device.register() before calling this._connectWithBackoff()
We're not doing this in this new flow - I guess it's because we assume that since we already have currentSocketUrl then it means we must have registered already, so I think it's fine, but just adding a comment to double check that you thought the same.


mockWebSocket.emit('close', {code: 1000, reason: 'Done'});

process.nextTick(() => mockWebSocket.open());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm a bit confused by this - why do we need to call this here? doesn't this make the check assert.calledTwice(Socket.prototype.open) that we do later in line 376 pointless because the 2 open() calls are done by the test not the code under test?

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.

2 participants