惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
J
Java Code Geeks
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
量子位
T
Tailwind CSS Blog
Vercel News
Vercel News
I
InfoQ
Stack Overflow Blog
Stack Overflow Blog
U
Unit 42
Engineering at Meta
Engineering at Meta
L
LangChain Blog
大猫的无限游戏
大猫的无限游戏
D
Docker
博客园_首页
P
Proofpoint News Feed
月光博客
月光博客
T
The Blog of Author Tim Ferriss
MyScale Blog
MyScale Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Martin Fowler
Martin Fowler
腾讯CDC
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(node-host): restart stale node host on version mismat...
scotthuang · 2026-05-27 · via Recent Commits to openclaw:main

@@ -0,0 +1,108 @@

1+

import fs from "node:fs";

2+

import path from "node:path";

3+

import { afterAll, beforeAll, describe, expect, test } from "vitest";

4+

import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";

5+

import { resolveRuntimeServiceVersion } from "../version.js";

6+

import { connectGatewayClient } from "./test-helpers.e2e.js";

7+

import { installGatewayTestHooks, startServer } from "./test-helpers.js";

8+9+

installGatewayTestHooks({ scope: "suite" });

10+11+

const gatewayVersion = resolveRuntimeServiceVersion(process.env);

12+13+

const TEST_LOCAL_NODE_ID = "test-local-node-version-mismatch";

14+15+

describe("node host version mismatch guard", () => {

16+

let port: number;

17+

let server: Awaited<ReturnType<typeof startServer>>["server"];

18+19+

beforeAll(async () => {

20+

// Write a node.json so the gateway's resolveLocalNodeId() finds it in the test state dir.

21+

const stateDir = process.env.OPENCLAW_STATE_DIR;

22+

if (stateDir) {

23+

fs.mkdirSync(stateDir, { recursive: true });

24+

fs.writeFileSync(

25+

path.join(stateDir, "node.json"),

26+

JSON.stringify({ version: 1, nodeId: TEST_LOCAL_NODE_ID }),

27+

);

28+

}

29+

const started = await startServer("secret");

30+

port = started.port;

31+

server = started.server;

32+

});

33+34+

afterAll(async () => {

35+

await server?.close();

36+

});

37+38+

test("local node with matching released version connects successfully", async () => {

39+

// Use the actual gateway version so versions match

40+

const client = await connectGatewayClient({

41+

url: `ws://127.0.0.1:${port}`,

42+

token: "secret",

43+

role: "node",

44+

clientName: GATEWAY_CLIENT_NAMES.NODE_HOST,

45+

clientDisplayName: "test-node-match",

46+

clientVersion: gatewayVersion,

47+

instanceId: TEST_LOCAL_NODE_ID,

48+

mode: GATEWAY_CLIENT_MODES.NODE,

49+

scopes: [],

50+

commands: [],

51+

});

52+

expect(client).toBeDefined();

53+

await client.stopAndWait({ timeoutMs: 2_000 });

54+

});

55+56+

test("local node with mismatched released version is rejected", async () => {

57+

const staleVersion = "2020.1.1";

58+

await expect(

59+

connectGatewayClient({

60+

url: `ws://127.0.0.1:${port}`,

61+

token: "secret",

62+

role: "node",

63+

clientName: GATEWAY_CLIENT_NAMES.NODE_HOST,

64+

clientDisplayName: "test-node-stale",

65+

clientVersion: staleVersion,

66+

instanceId: TEST_LOCAL_NODE_ID,

67+

mode: GATEWAY_CLIENT_MODES.NODE,

68+

scopes: [],

69+

commands: [],

70+

timeoutMs: 5_000,

71+

timeoutMessage: "expected version mismatch rejection",

72+

}),

73+

).rejects.toThrow(/client version mismatch|version mismatch/i);

74+

});

75+76+

test("local node with dev/test version is allowed (not a released version)", async () => {

77+

// "dev" does not match YYYY.M.D, so the guard skips

78+

const client = await connectGatewayClient({

79+

url: `ws://127.0.0.1:${port}`,

80+

token: "secret",

81+

role: "node",

82+

clientName: GATEWAY_CLIENT_NAMES.NODE_HOST,

83+

clientDisplayName: "test-node-dev",

84+

clientVersion: "dev",

85+

mode: GATEWAY_CLIENT_MODES.NODE,

86+

scopes: [],

87+

commands: [],

88+

});

89+

expect(client).toBeDefined();

90+

await client.stopAndWait({ timeoutMs: 2_000 });

91+

});

92+93+

test("local node with non-date version '1.0.0' is allowed", async () => {

94+

const client = await connectGatewayClient({

95+

url: `ws://127.0.0.1:${port}`,

96+

token: "secret",

97+

role: "node",

98+

clientName: GATEWAY_CLIENT_NAMES.NODE_HOST,

99+

clientDisplayName: "test-node-semver",

100+

clientVersion: "1.0.0",

101+

mode: GATEWAY_CLIENT_MODES.NODE,

102+

scopes: [],

103+

commands: [],

104+

});

105+

expect(client).toBeDefined();

106+

await client.stopAndWait({ timeoutMs: 2_000 });

107+

});

108+

});