Uncaught (in promise) TypeError: Cannot read properties of null (reading 'postMessage')
Frosty21 opened this issue · 13 comments
Hi there,
My team is having this error creeping up and was wondering if you could clarify on this as it is not in talk.types.d.ts
for postMessage.
Updated after bumping TalkJS from "^0.15.2" to "^0.15.4" error issue is no more. please update this in the readme changelogs cheers
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'postMessage')
at u (talk.js:18:5962)
at Object.r (talk.js:18:5434)
at talk.js:18:58215
u @ talk.js:18
r @ talk.js:18
(anonymous) @ talk.js:18
Promise.then (async)
post @ talk.js:18
t.onWindowVisibleChanged @ talk.js:18
n @ talk.js:18
(anonymous) @ talk.js:18
Hi there,
Just to clarify, are you still experiencing this bug or has this been resolved?
We did recently fix a bug that may have caused this error message. The fix was in cloud-served code however, so updating the npm package version should have not affected that. It's possible, however, that you updated to the new version around the same time as shipped said bugfix.
We'll try to be better at including exhaustive bug fixes in the changelog, thanks for that suggestion.
Yep it’s all fixed I just wanted to document it if someone has the same issue.
If you can update it into the change log that would be awesome cheers.
Another question is there a way to disable the warning message from the newest version?
Which warning message are you referring to, in particular? Can you eg show a screenshot with the devtools console open or something like that? Thanks
tracker.js:13 Warning: a promise was rejected with a non-error: [object Event] at g (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:524:10200) at i.t._warn (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:524:14808) at i._rejectCallback (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:524:36514) at IDBOpenDBRequest.<anonymous> (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:524:36757)From previous event: at i.p [as _captureStackTrace] (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:524:9202) at i._resolveFromExecutor (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:524:36637) at new i (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:524:28920) at s (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:16:1021) at t.componentDidMount (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:556:173586) at Ma (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:82138) at ja (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:85060) at https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:98138 at Object.t.unstable_runWithPriority (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:483:3216) at ws (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:98072) at Ts (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:97848) at Ss (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:97193) at _s (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:96214) at qa (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:95083) at Is (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:99107) at Rs (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:99161) at js.render (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:102959) at https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:100979 at ks (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:98381) at Hs (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:100911) at Object.hydrate (https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:475:103904) at https://cdn.talkjs.com/browser-bundle-release-294c2b7.js:556:234335
its in the logs also
thanks! this looks like it may be another bug altogether. we'll look into it.
Can you give me some more context maybe?
- Does it happen consistently or sometimes?
- Does it happen when the chat UI loads immediately, or after doing a particular user action?
If you have a live (staging) app that we could navigate to to try to reproduce this, that'd be extremely helpful. If there's private credentials to share, consider using the live support chat on our website (https://talkjs.com) or emailing to dev@talkjs.com
Thanks!
I've engaged with the live support chat just then. Its when we are in local environment the modal for talkJS chat box goes blank with warn error message whereas development in AWS works fine with no warn error message or black talkjs chat box modal...
Thanks, we'll continue the conversation on the chat.
Closing this issue since your initial problem has been solved. We'll continue the discussion about the warning in support chat .
Oh man my team figured out the issue it was on our side our default image wasn't rendering for the photoUrl...
What was weird though was that logzio error reporting only give it as a code 2 error but when console.log(error) the error was visible. We'll probably transform the error so its readable on logzio but something for your team to consider as a use case with the error messages.
The newest version of talkjs 0.15.4 is working fine
I see this issue in 0.15.5 when I recreate the basic react example or NextJS example. It causes the chat box to not appear on first load. Strangely, after the initial mount cycle, if I then change some code to cause a HMR, the chat box then appears. Here is the code (just the one file)
@michaelaflores found any solution to issue you are facing? facing same issue, tried using 0.15.4, still same issue is there, first load it gives this error in console TypeError: Cannot convert undefined or null to object
Hi there. We think this issue is caused by the way our examples initialize everything when the component is mounted using useEffect
, but then don't clean it up when the component is unmounted, so if the component gets unmounted and remounted again, this code is run twice, and something goes wrong. We're going through our docs and examples, and updating them, but in the meantime, have a look at this codesandbox, and see if changing your code like this fixes the issue for you:
https://codesandbox.io/s/vigilant-varahamihira-sr4heb?file=/src/App.js