mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 12:18:37 +00:00
perf: speed up gateway missing-tick e2e watchdog
This commit is contained in:
@@ -70,6 +70,7 @@ describe("GatewayClient", () => {
|
|||||||
const client = new GatewayClient({
|
const client = new GatewayClient({
|
||||||
url: `ws://127.0.0.1:${port}`,
|
url: `ws://127.0.0.1:${port}`,
|
||||||
connectDelayMs: 0,
|
connectDelayMs: 0,
|
||||||
|
tickWatchMinIntervalMs: 5,
|
||||||
onClose: (code, reason) => resolve({ code, reason }),
|
onClose: (code, reason) => resolve({ code, reason }),
|
||||||
});
|
});
|
||||||
client.start();
|
client.start();
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ type Pending = {
|
|||||||
export type GatewayClientOptions = {
|
export type GatewayClientOptions = {
|
||||||
url?: string; // ws://127.0.0.1:18789
|
url?: string; // ws://127.0.0.1:18789
|
||||||
connectDelayMs?: number;
|
connectDelayMs?: number;
|
||||||
|
tickWatchMinIntervalMs?: number;
|
||||||
token?: string;
|
token?: string;
|
||||||
password?: string;
|
password?: string;
|
||||||
instanceId?: string;
|
instanceId?: string;
|
||||||
@@ -376,7 +377,12 @@ export class GatewayClient {
|
|||||||
if (this.tickTimer) {
|
if (this.tickTimer) {
|
||||||
clearInterval(this.tickTimer);
|
clearInterval(this.tickTimer);
|
||||||
}
|
}
|
||||||
const interval = Math.max(this.tickIntervalMs, 1000);
|
const rawMinInterval = this.opts.tickWatchMinIntervalMs;
|
||||||
|
const minInterval =
|
||||||
|
typeof rawMinInterval === "number" && Number.isFinite(rawMinInterval)
|
||||||
|
? Math.max(1, Math.min(30_000, rawMinInterval))
|
||||||
|
: 1000;
|
||||||
|
const interval = Math.max(this.tickIntervalMs, minInterval);
|
||||||
this.tickTimer = setInterval(() => {
|
this.tickTimer = setInterval(() => {
|
||||||
if (this.closed) {
|
if (this.closed) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user