Skip to content

Undefined reference in SendFailed.tsx - TypeError: Cannot read properties of undefined (reading 'has') #5812

@peterinnesmsft

Description

@peterinnesmsft

Is it an issue related to Adaptive Cards?

No

Is this an accessibility issue?

No

What version of Web Chat are you using?

Latest production

Which distribution are you using Web Chat from?

Bundle (webchat.js)

Which hosting environment does this issue primarily affect?

Dynamics 365 Omnichannel

Which browsers and platforms do the issue happened?

Browser: Chrome (latest)

Which area does this issue affect?

Chat history

Which theme pack does this issue affect?

I did not test it on other theme packs

What is the public URL for the website?

No response

Please describe the bug

We are seeing the following error in our application telemetry on attempting to render the web chat control, which appears to be causing rendering errors from what is reported by our own customers:

TypeError: Cannot read properties of undefined (reading 'has')

This is coming from the bundled webChat.js, and GitHub Copilot has provided the following failing region at which the issue is occurring:

uE = () => {
   let [e] = cE(),           // sendStatusByActivityKey (Map)
       t = aE(),             // activity key resolver
       r = sE(),             // localization hook
       n = oE(),             // live region announcer
       // Build Set of failed activity keys:
       i = useMemo(() =>
         Array.from(e).reduce(
           (e, [r, n]) => n !== tE || Dy(t(r)) ? e : e.add(r),
           new Set()
         ), [t, e]),
       o = r("TRANSCRIPT_LIVE_REGION_SEND_FAILED_ALT"),
       a = rE(i),            // usePrevious(i) → undefined on 1st render
       s = useMemo(() => {
         if (i === a) return false;
         for (let e of i.keys())
           if (!a.has(e))     // 💥 a is undefined on first mount
             return true;
         return false;
       }, [i, a]);
   return useEffect(() => { s && n(o) }, [s, o, n]), null;
 };

This appears to be an issue in SendFailed.tsx in which we can have an undefined value for prevActivityKeysOfSendFailed based on rendering order.

Do you see any errors in console log?

See above.

How to reproduce the issue?

Still determining exact repro steps.

What do you expect?

No errors. :)

What actually happened?

Customer reports indicate that the web chat control can fail to render; in cases where this has been reported, we see this error, so we believe this is linked to the observed experience.

Do you have any screenshots or recordings to repro the issue?

Not available.

Adaptive Card JSON

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bot ServicesRequired for internal Azure reporting. Do not delete. Do not change color.bugIndicates an unexpected problem or an unintended behavior.customer-reportedRequired for internal Azure reporting. Do not delete.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions