error "Cannot read properties of null (reading 'postMessage')"
See original GitHub issueversion: 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:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Fixed in v6.6.2. Thanks for reporting and for the details!