Uncaught TypeError: Cannot read property 'postMessage' of undefined

i am trying to get the product name and post it inside my html but i have this error:
Uncaught TypeError: Cannot read property ‘postMessage’ of undefined.
i used debugger and the productName is sent but as the code continue to run something is wix code breaks and i have that error, can anyone please help

import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady( async function () {
let product = await $w("#productPage1").getProduct();
if (product) {
let productName = product.name;
$w("#html1").postMessage(productName);
}
} );

I’m currently facing the same problem. Did you find a solution?

You can see more about working with the html element here.
https://support.wix.com/en/article/corvid-working-with-the-html-element
https://www.wix.com/corvid/reference/$w.HtmlComponent.html

Also, take a look at this example here.
https://support.wix.com/en/article/corvid-tutorial-adding-ratings-and-reviews-to-a-wix-stores-site

Try it as the example shows first and see if it just runs with product.

import wixData from 'wix-data';
import wixWindow from 'wix-window';
let product; 

$w.onReady(async function () {
product = await $w('#productPage1').getProduct();  

Understanding the Code
Lines 1-2: Import the modules we need to work with Wix Data and Wix Window libraries.
Line 5: Define the global product variable.
Line 7: When the page loads, do the following:
Line 8: Using the getProduct function on the current product page, set the product variable to the currently displayed product.

Or simply try it as getProduct in the Wix API Reference.
https://www.wix.com/corvid/reference/$w.ProductPage.html#getProduct

Examples
Get the current product’s information

$w('#myProductPage').getProduct()
  .then( (product) => {
    let productName = product.name;
    let productDescription = product.description;
    // see example product object below
  } )
  .catch( (error) => {
    console.log(error);
  } );

/*
 * Example product object:
 *
 * {
 *   "_id": "3fb6a3c8-988b-8755-04bd-5c59ae0b18ea",
 *   "_updatedDate: "2020-1-26T11:24:25.607Z"
 *   "name": "Product Name",
 *   "description": "Product description",
 *   "mainMedia": "wix:image://v1/a...3.jpg/file.jpg#originWidth=1000&originHeight=1000",
 *   "mediaItems": [
 *     {
 *       "id": "a...3.jpg",
 *       "src": "wix:image://v1/a...3.jpg/file.jpg#originWidth=1000&originHeight=1000",
 *       "description": "Media desc",
 *       "title": "Media title",
 *       "type": "Image"
 *     }
 *   ],
 *   "sku": "36523641234523",
 *   "ribbons": [
 *     {
 *       "text": "New and Improved"
 *     }
 *   ],
 *   "currency": "USD",
 *   "price": 15,
 *   "discountedPrice": 12,
 *   "formattedPrice": "$15.00",
 *   "formattedDiscountedPrice": "$12.00",
 *   "discount": {
 *     "type": "PERCENT",
 *     "value" :20
 *   },
 *   "trackInventory": true,
 *   "inStock": true,
 *   "quantityInStock": "100",
 *   "additionalInfoSections": [
 *     {
 *       "title": "Product info",
 *       "description": "Product detail."
 *     }
 *   ],
 *   "productOptions": {
 *     "Size": {
 *       "optionType": "drop_down",
 *       "name": "Size",
 *       "choices": [
 *         {
 *           "value": "Small",
 *           "description": "Small",
 *           "inStock": true,
 *           "visible": true
 *         },
 *         {
 *           "value": "Large",
 *           "description": "Large",
 *           "inStock": true,
 *           "visible": true
 *         }
 *       ]
 *   },
 *   "productPageUrl": "/product-page/i-m-a-product",
 *   "manageVariants": true,
 *   "customTextFields": [
 *     { 
 *       "title": "New Custom Text",
 *       "maxLength": 500,
 *       "mandatory": true
 *     }
 *   ],
 *   "productType": "physical",
 *   "slug": "my-product",
 *   "weight": 10,
 *   "variants": [
 *     {
 *       "_id":"00000000-0000-0020-0005-97ae39161f00",
 *       "choices": {
 *         "Size": "Small"
 *       },
 *       "variant": {
 *         "currency": "USD",
 *         "price": 15,
 *         "discountedPrice": 12,
 *         "formattedPrice": "$15.00",
 *         "formattedDiscountedPrice":"$12.00",
 *         "weight":10,
 *         "sku":"217537123517253",
 *         "visible":true
 *       }
 *     }, {
 *       "_id":"00000000-0000-0021-0005-97ae39161f00",
 *       "choices": {
 *         "Size": "Large"
 *       },
 *       "variant": {
 *         "currency": "USD",
 *         "price": 15,
 *         "discountedPrice": 15,
 *         "formattedPrice": "$15.00",
 *         "formattedDiscountedPrice":"$15.00",
 *         "weight":12,
 *         "sku":"217537123517253",
 *         "visible":true
 *       }
 *    }
 *  ]
 */