mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 06:51:36 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -2,7 +2,9 @@ import { createServer } from "node:net";
|
||||
import { isMainThread, threadId } from "node:worker_threads";
|
||||
|
||||
async function isPortFree(port: number): Promise<boolean> {
|
||||
if (!Number.isFinite(port) || port <= 0 || port > 65535) return false;
|
||||
if (!Number.isFinite(port) || port <= 0 || port > 65535) {
|
||||
return false;
|
||||
}
|
||||
return await new Promise((resolve) => {
|
||||
const server = createServer();
|
||||
server.once("error", () => resolve(false));
|
||||
@@ -66,7 +68,9 @@ export async function getDeterministicFreePortBlock(params?: {
|
||||
const ok = (await Promise.all(offsets.map((offset) => isPortFree(start + offset)))).every(
|
||||
Boolean,
|
||||
);
|
||||
if (!ok) continue;
|
||||
if (!ok) {
|
||||
continue;
|
||||
}
|
||||
nextTestPortOffset = (nextTestPortOffset + attempt + blockSize) % usable;
|
||||
return start;
|
||||
}
|
||||
@@ -79,7 +83,9 @@ export async function getDeterministicFreePortBlock(params?: {
|
||||
const ok = (await Promise.all(offsets.map((offset) => isPortFree(port + offset)))).every(
|
||||
Boolean,
|
||||
);
|
||||
if (ok) return port;
|
||||
if (ok) {
|
||||
return port;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error("failed to acquire a free port block");
|
||||
|
||||
Reference in New Issue
Block a user