question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error "Cannot read properties of null (reading 'postMessage')"

See original GitHub issue

version: 5.3.0 I am getting getting this error:

handleSynMessageFactory.js:16 Uncaught TypeError: Cannot read properties of null (reading 'postMessage')
    at handleSynMessageFactory.js:16:1
    at handleMessage (connectToChild.js:35:1)

It seems to come form this line of code:

// at parent/handleSynMessageFactory:
event.source.postMessage(synAckMessage, originForSending);

Usually the source is a window, so I’m guessing this is happening because the parent window is getting a message from an iframe that already closed (similar to the connectionDestroyed error during handshake).

Maybe add a null guard there?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
KutnerUricommented, Mar 9, 2022

I don’t remember 100%, but I think it had some race condition because of server-side rendering.

When the site is pre-generated on the server, it loads the entire html, including iframes, so the browser loads/executes both the parent and child iframe at the same time. The main site takes a while to execute/rehydrate until it finally reaches the react hook that starts listening The child iframe is much simpler, and it sometimes manages to reach .connectToParent early enough, it didn’t get a response and just time out.

1reaction
Aaroniuscommented, Mar 6, 2022

Fixed in v6.6.2. Thanks for reporting and for the details!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'postMessage' of null · Issue #171 ...
When I run my Aurelia application, I get this error: Uncaught TypeError: Cannot read property 'postMessage' of null .
Read more >
Cannot read property 'postMessage' of undefined ` error while ...
The problem is that, when I click Send message on child website and call socket. postMessage() it says Uncaught TypeError: Cannot read property ......
Read more >
Uncaught TypeError: Cannot read property 'postMessage' of null
After successfully login, the following message appears. Uncaught TypeError: Cannot read property 'postMessage' of null at checkLoginIframe (keycloak.js:1139)
Read more >
Cannot read property 'postMessage' of undefined : r/javascript
Getting the above error when trying to post message to web worker. Created the worker then trying to postmessage from within function.
Read more >
Worker.postMessage() - Web APIs | MDN
The postMessage() method of the Worker interface sends a message to the worker's inner scope. This accepts a single parameter, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found