title: DataCloneError: #<Promise> could not be cloned
body: <p>I am using worker thread in node js, below is my code in two files</p>
  <p><code>worker.js</code></p>
  <pre><code>const mysql = require('mysql2');
  const { 
  v1: uuidv1,
  v4: uuidv4,
  } = require('uuid');
  const {parentPort, workerData} = require(&quot;worker_threads&quot;);
  
  const dayjs = require('dayjs');
  
  parentPort.postMessage(getRdvSlots(workerData.data));
  
  async function getRdvSlots(data){
    if(data.duration == 0 || data.address_id.trim() === &quot;&quot; || data.reasonId.trim() === &quot;&quot; || data.people_id.trim() === &quot;&quot; ){
      return false;
    }
    let details = {};
  
    let startDate = data.sel_date;
    details[&quot;startDate&quot;] = startDate;
  
    let availableDates = await generateAvailableDates(data.people_id, data.address_id, data.reasonId, startDate);
  
    let emptyAvailabilities = 0;
    let slots = {};
    for(let key in availableDates){
      slots[key] = await getSlots(key, availableDates[key],data.people_id, data.duration);
    }
    details[&quot;slots&quot;] = slots;
  
    return JSON.parse(JSON.stringify(details));
  }
  </code></pre>
  <p>And in index.js</p>
  <pre><code>app.get(&quot;/checkworker&quot;, async (req, res) =&gt; {
      const worker = new Worker(&quot;./worker.js&quot;, {workerData: {data: req.query}});
  
      worker.once(&quot;message&quot;, result =&gt; {
          console.log(`${result}`);
          res.send(result);
      });
  
      worker.on(&quot;error&quot;, error =&gt; {
          console.log(error);
      });
  
      worker.on(&quot;exit&quot;, exitCode =&gt; {
          console.log(`It exited with code ${exitCode}`);
      })
  });
  </code></pre>
  <p>In this I am getting error of</p>
  <blockquote>
  <p>DataCloneError: # could not be cloned.
  at Object. \worker.js:10:12</p>
  </blockquote>
  <p>which is at line <code>parentPort.postMessage(getRdvSlots(workerData.data));</code> in worker.js</p>
  <p>I am new to nodejs worker thread any help what is error in my code</p>