Using socket.io with worker threads node.js

Hi,
I have setup my node.js server which has three worker(thread) files.
worker 1 read a large json file and send each json to worker 2.
worker 2 read that json file and sends to worker 3 after a interval(based on timestamp property associated with that json).
and worker 3 just console that to the terminal.

worker3.js

if(!isMainThread){
parentPort.on('message', (data)=>{
console.log(data)
})
}

worker1.js

const readline = require('readline');
async function processLineByLine() {
  const fileStream = fs.createReadStream('trades.json');
  const rl = readline.createInterface({
    input: fileStream,
    crlfDelay: Infinity
  });
  const worker = new Worker('./worker2.js');
  for await (const line of rl) {
    worker.postMessage(JSON.parse(line))
  }
}
processLineByLine();

Now i wish to create the front end of this application.
In which when the react component mounts then i will make an ajax call to the express server.
this express server will have a route which will call my processLineByLine method of worker1.js and worker3.js will have emit an event with the data to the client socket.

I tried many things like exporting the socket from index.js to worker3.js and vice versa.
but nothing seems to work everytime i get unhandled error.

App.js

import socketIOClient from "socket.io-client";
const endpoint='http://localhost:4001';
class App extends React.Component{
  componentDidMount(){
    Api.get('/trades')
    const socket = socketIOClient(endpoint);
    socket.on("trade", data => console.log(data));
  }

index.js(server)

const start=require('./worker1')
const socket=require('socket.io')
const app=express()
const io=socket(server)
app.use(cors())
app.get('/trades', (req,res)=>{
  try{
    start. processLineByLine()
  }})

const server=app.listen(4001,()=>{
  console.log(`server listening on port 4001`)
})

please help!!!