Помоги решить следующую ошибку 
PS D:\dev\vue-electron-apps\overboard-app> node server.js
WebSocket server is running on:
  Local: ws://localhost:8080
  Network: ws://26.161.24.213:8080
Player ready. Ready players: 1
D:\dev\vue-electron-apps\overboard-app\server.js:134
        client.send(JSON.stringify({command:'get_id', id: index}));
                         ^

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Socket'
    |     property '_writableState' -> object with constructor 'WritableState'
    |     property 'afterWriteTickInfo' -> object with constructor 'Object'
    --- property 'stream' closes the circle
    at JSON.stringify (<anonymous>)
    at D:\dev\vue-electron-apps\overboard-app\server.js:134:26
    at Set.forEach (<anonymous>)
    at onInitRoles (D:\dev\vue-electron-apps\overboard-app\server.js:132:17)
    at WebSocket.<anonymous> (D:\dev\vue-electron-apps\overboard-app\server.js:167:9)
    at WebSocket.emit (node:events:513:28)
    at Receiver.receiverOnMessage (D:\dev\vue-electron-apps\overboard-app\node_modules\ws\lib\websocket.js:1220:20)
    at Receiver.receiverOnMessage (D:\dev\vue-electron-apps\overboard-app\node_modules\ws\lib\websocket.    at Receiver.receiverOnMessage (D:\dev\vue-electron-apps\overboard-app\node_modules\ws\lib\websocket.js:1220:20)
    at Receiver.emit (node:events:513:28)
    at Receiver.dataMessage (D:\dev\vue-electron-apps\overboard-app\node_modules\ws\lib\receiver.js:596:14)
    at Receiver.getData (D:\dev\vue-electron-apps\overboard-app\node_modules\ws\lib\receiver.js:496:10) 

Node.js v18.13.0



const { RESOURCES, initResources } = require('./data/resources.js');
const WebSocket = require('ws');
const os = require('os');

function broadcast(data) {
  wss.clients.forEach(client => {
    if (client.readyState === WebSocket.OPEN) {
      client.send(JSON.stringify(data));
    }
  });
}

function getLocalIp() {
  const interfaces = os.networkInterfaces();
  for (const name of Object.keys(interfaces)) {
    for (const net of interfaces[name]) {
      // Пропускаем внутренние и не-IPv4 интерфейсы
      if (net.family === 'IPv4' && !net.internal) {
        return net.address;
      }
    }
  }
  return 'localhost'; // Fallback
}
const LOCAL_IP = getLocalIp();
const WS_PORT = 8080;

const wss = new WebSocket.Server({ host: '0.0.0.0', port: WS_PORT });

const roles = ['lady', 'sir', 'captain', 'fmate', 'frenchy', 'kid'];

let player = {
  nickname: '',
  role: '',
  friend: '',
  foe: '',
}

let gameState = {
  isGameStarted: false,
  round: 0,
  phase: 'init',
  players: [],
  resources: initResources,
  threats: [],
  turn: {
    currentPlayerId: 0,
    phase: ''
  },
  gameStatus: ''
}

const games = new Map();
wss.on('connection', (ws) => {
  ws.player = player;
  ws.isPlaying = false;

  ws.send(JSON.stringify({
    type: 'FULL_STATE_UPDATE',
    state: gameState,
  }))

  function broadcastPlayerStats() {
    const playerCount = Array.from(wss.clients).filter(
      client => client.isPlaying && client.readyState === WebSocket.OPEN
    ).length;
    const totalCount = Array.from(wss.clients).filter(
      client => client.readyState === WebSocket.OPEN
    ).length;

    broadcast({
      command: 'player_stats',
      playerCount,
      totalCount,
    });
  }

  function broadcastState() {
    broadcast({
      type: 'FULL_STATE_UPDATE',
      state: gameState
    });
  }

  function onPlay() {
    if (!ws.isPlaying) {
      ws.isPlaying = true;
      broadcastPlayerStats();

      console.log(`Player ready. Ready players: ${Array.from(wss.clients).filter(
        client => client.isPlaying && client.readyState === WebSocket.OPEN
      ).length}`);

      //gameState.players.push(ws.player);
    }
  }

  function onChatMessage(msg) {
    broadcast({
      command: 'chat_message',
      text: msg.text,
      nickname: msg.nickname,
    });
  }

  function onInitRoles() {
    const players = Array.from(wss.clients).filter(client =>
      client.isPlaying && client.readyState === WebSocket.OPEN
    );

    if (players.length > roles.length) {
      ws.send(JSON.stringify({ error: 'Not enough roles for all players' }));
      return;
    }

    const shuffledRoles = [...roles].sort(() => Math.random() - 0.5).slice(players.length);
    const foeRoles = [...roles].sort(() => Math.random() - 0.5).slice(players.length);
    const friendRoles = [...roles].sort(() => Math.random() - 0.5).slice(players.length);

    gameState.players = players.map((client, index) => ({
      id: index + 1,
      role: shuffledRoles[index],
      foe: foeRoles[index],
      friend: friendRoles[index],
      id: index
    }));

    broadcastState();


    /// Sending index to every user
    wss.clients.forEach((client, index) => {
      if (client.readyState === WebSocket.OPEN) {
        client.send(JSON.stringify({command:'get_id', id: index}));
      }
    });
    return { success: true };
  }

  // function onGameIsStarted() {
  //   gameState.gameStatus = true;

  //   broadcast(JSON.stringify({command: 'game_is_started', gameState}))
  // }

  function startGame() {
    gameState.isGameStarted = true;
    gameState.gameStatus = 'playing';
    broadcastState();
  }

  ws.on('message', (message) => {
    let msg;
    try {
      msg = JSON.parse(message);
    } catch (e) {
      ws.send(JSON.stringify({ error: 'Invalid message format, must be JSON' }));
      return;
    }

    switch (msg.command) {
      case 'play':
        onPlay();
        break;

      case 'init_roles':
        onInitRoles();
        break;

      case 'start_game':
        startGame();
        break;

      case 'chat_message':
        onChatMessage(msg);
        break;

      default:
        ws.send(JSON.stringify({ error: 'Unknown command' }));
    }
  });

  ws.on('close', () => {
    if (ws.isPlaying) {
      ws.isPlaying = false;
      broadcastPlayerStats();

      console.log(`Player left. Ready players: ${Array.from(wss.clients).filter(
        client => client.isPlaying && client.readyState === WebSocket.OPEN
      ).length}`);
    }
  });
});

console.log(`WebSocket server is running on:
  Local: ws://localhost:${WS_PORT}
  Network: ws://${LOCAL_IP}:${WS_PORT}`);