diff --git a/src/server/api/api.ts b/src/server/api/api.ts index ad6cb04..cdcd1d5 100644 --- a/src/server/api/api.ts +++ b/src/server/api/api.ts @@ -150,8 +150,9 @@ apiRouter.get("/get-ids", (_, res) => { apiRouter.get("/do-smth", async (_, res) => { const robotsEntries = Array.from(virtualRobots.entries()); + const randomRobotIndex = Math.floor(Math.random() * robotsEntries.length) const [, robot] = - robotsEntries[Math.floor(Math.random() * robotsEntries.length)]; + robotsEntries[randomRobotIndex]; await robot.sendDrivePacket(1); await robot.sendTurnPacket(45 * DEGREE); diff --git a/src/server/api/client-manager.ts b/src/server/api/client-manager.ts index 536ce6b..32bbf99 100644 --- a/src/server/api/client-manager.ts +++ b/src/server/api/client-manager.ts @@ -60,7 +60,7 @@ export class ClientManager { } } - public getIds(): undefined | string[] { + public getIds(): undefined | [string, string] { if (this.hostId && this.clientId) { return [this.hostId, this.clientId]; } else { diff --git a/src/server/simulator.ts b/src/server/simulator.ts index fe18222..67ef7ea 100644 --- a/src/server/simulator.ts +++ b/src/server/simulator.ts @@ -44,6 +44,9 @@ const parseErrorStack = (stack: string): StackFrame[] => { throw new Error(`Invalid stack frame: ${line}`); } const [, functionName, fileName, lineNumber, columnNumber] = match; + if (!functionName || !fileName || !lineNumber || !columnNumber) { + throw new Error(`Invalid stack frame: ${line}`); + } return { fileName, functionName,