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);
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?
- Created a year ago
- Comments:9 (9 by maintainers)
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!