daily-co / daily-js

https://docs.daily.co/reference/daily-js
BSD 2-Clause "Simplified" License
103 stars 33 forks source link

TypeError: Cannot read properties of null (reading 'postMessage') #230

Closed ahkhanjani closed 11 months ago

ahkhanjani commented 1 year ago

Using Daily prebuilt 0.54.0, React 18.2.0, Next.js 14.0.3,

Only sometimes this error occurs:

Unhandled Runtime Error
TypeError: Cannot read properties of null (reading 'postMessage')

  64 | const createAndJoinCall = useCallback(() => {
  65 |   if (!callRef.current) return;
> 66 |   const newCallFrame = DailyIframe.createFrame(callRef.current, CALL_OPTIONS);
     |                                   ^
  67 |
  68 |   setCallFrame(newCallFrame);
  69 |

Refreshing the page solves it. So it seems quite random. This is the client-side exception I mentioned in #229 and I'm not sure what's causing it. Since there is a problem with cleaning up effect, I assumed it has something to do with that.

mattieruth commented 12 months ago

Thanks for the report! I'm not sure if something changed with Chrome's page load, but it seems like we are seeing issues more frequently on startup where the window isn't yet defined globally. We recently patched many of the places where this would trip us up but it looks like I missed this one. I've filed an internal bug and will try to squash it in the next release or two.

ahkhanjani commented 11 months ago
Fix some insecure window.postMessage() calls.

Hi @mattieruth. I assume this should be fixed now?

ahkhanjani commented 11 months ago

Seems to be fixed. Thank you

mattieruth commented 11 months ago

Yes! This was resolved in 0.56.0. Thank you for confirming.