Skip to content

addVoiceFocus recreates reference on empty device string causing infinite rerender when calling inside passive effect #1006

@denniscual

Description

@denniscual

What happened and what did you expect to happen?

If the device passed to addVoiceFocus is an empty string, the function still calls:

const vf = await transformer?.createTransformDevice(device);
      if (vf) {
        logger.info('Created a new Amazon Voice Focus transform device.');
        setVoiceFocusDevice(vf);
        return vf;
      }

This causes vf to be created and subsequently setVoiceFocusDevice(vf) is invoked, which leads to a new reference for addVoiceFocus on every render.

If addVoiceFocus is called inside an effect and included as a dependency, this results in an infinite rerender.

2025-10-20.18-08-47.mov

Recommendation:

  • Add an early exit: don’t call transform if device is empty.
  • Memoize addVoiceFocus so its reference remains stable when device doesn’t change.

Have you reviewed our existing documentation?

Reproduction steps

Steps to Reproduce:

  • Call addVoiceFocus with an empty string as the device.
  • Observe that createTransformDevice is invoked.
  • Include addVoiceFocus in a React effect dependency array.
  • Notice infinite rerendering.

Amazon Chime SDK React Components Library version

^3.11.0

What browsers are you seeing the problem on?

Chrome dev, comet

Browser version

Version 143.0.7475.7

Device Information

MacBook Pro; 14.1 (23B74)

Meeting and Attendee ID Information.

No response

Browser console logs

ConsoleLogger.js:79 2025-10-20T10:23:57.861Z [INFO] ChimeSDKReactComponent - Created a new Amazon Voice Focus transform device.

ConsoleLogger.js:79 2025-10-20T10:23:58.083Z [INFO] ChimeSDKReactComponent - Created a new Amazon Voice Focus transform device.

ConsoleLogger.js:79 2025-10-20T10:23:58.339Z [INFO] ChimeSDKReactComponent - Created a new Amazon Voice Focus transform device.

ConsoleLogger.js:79 2025-10-20T10:23:58.879Z [INFO] ChimeSDKReactComponent - Created a new Amazon Voice Focus transform device.

ConsoleLogger.js:79 2025-10-20T10:23:59.029Z [INFO] ChimeSDKReactComponent - Created a new Amazon Voice Focus transform device.

Add any other context about the problem here.

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions