Skip to content

[Crash] Unchecked worker message array destructuring in roomManager #63

@coderabbitai

Description

@coderabbitai

Summary

Room manager crashes when worker sends malformed message array.

Affected Code

server-game/src/roomManager.js:201

worker.on('message', (msg) => {
  const [ msgType, content, wsId ] = msg; // CRASH if msg is not array or too short

Vulnerability

If worker sends non-array or incomplete array, destructuring fails.

Impact

  • Game server crash on worker communication
  • Room becomes unresponsive

Recommended Fix

worker.on('message', (msg) => {
  if (!Array.isArray(msg) || msg.length < 3) {
    console.error('Invalid worker message format:', msg);
    return;
  }
  const [ msgType, content, wsId ] = msg;

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions