perf: fast path session store json parsing · openclaw/openclaw@be3af54
steipete
·
2026-05-31
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -51,10 +51,12 @@ describe("state migration fs helpers", () => {
|
51 | 51 | it("parses json5 session stores and rejects invalid shapes", async () => { |
52 | 52 | await withTempDir({ prefix: "openclaw-state-migrations-fs-" }, async (base) => { |
53 | 53 | const okPath = path.join(base, "store.json"); |
| 54 | +const jsonPath = path.join(base, "plain.json"); |
54 | 55 | const badPath = path.join(base, "bad.json"); |
55 | 56 | const listPath = path.join(base, "list.json"); |
56 | 57 | |
57 | 58 | fs.writeFileSync(okPath, "{session: {sessionId: 'abc', updatedAt: 1}}", "utf8"); |
| 59 | +fs.writeFileSync(jsonPath, '{"session":{"sessionId":"json","updatedAt":2}}', "utf8"); |
58 | 60 | fs.writeFileSync(badPath, "{not valid", "utf8"); |
59 | 61 | fs.writeFileSync(listPath, "[]", "utf8"); |
60 | 62 | |
@@ -67,6 +69,15 @@ describe("state migration fs helpers", () => {
|
67 | 69 | }, |
68 | 70 | }, |
69 | 71 | }); |
| 72 | +expect(readSessionStoreJson5(jsonPath)).toEqual({ |
| 73 | +ok: true, |
| 74 | +store: { |
| 75 | +session: { |
| 76 | +sessionId: "json", |
| 77 | +updatedAt: 2, |
| 78 | +}, |
| 79 | +}, |
| 80 | +}); |
70 | 81 | expect(readSessionStoreJson5(badPath)).toEqual({ ok: false, store: {} }); |
71 | 82 | expect(readSessionStoreJson5(listPath)).toEqual({ ok: false, store: {} }); |
72 | 83 | }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。