Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(pg-type-cache): skip saving parameter types that did not change (#8647)
garrytan80532e83709d
diff --git a/src/core/pg-type-cache.ts b/src/core/pg-type-cache.tsindex 7621667ba1..382a1560ce 100644--- a/src/core/pg-type-cache.ts+++ b/src/core/pg-type-cache.ts@@ -52,8 +52,11 @@ export class SharedParameterTypes extends Map<string, number[]> {}override set(key: string, types: number[]): this {+ const hashed = digest(key);+ const known = super.get(hashed);+ if (known && known.length === types.length && known.every((type, i) => type === types[i])) return this;if (super.size >= MAX_ENTRIES) return this;- super.set(digest(key), types);+ super.set(hashed, types);this.changed();return this;}diff --git a/test/pg-type-cache.test.ts b/test/pg-type-cache.test.tsindex 646b24ea83..bc34ce92ee 100644--- a/test/pg-type-cache.test.ts+++ b/test/pg-type-cache.test.ts@@ -56,6 +56,17 @@ test('a second process with the same scope starts with the first one\'s describeexpect(statSync(file!).mode & 0o777).toBe(0o600);}));+test('#8647: a re-describe with the same types leaves the file alone; changed types are saved', () => withHome(home => {+ processRun(['160004', '112'], [25, 25]);+ const [file] = cacheFiles(home);+ const written = statSync(file!).ino;+ expect(processRun(['160004', '112'], [25, 25]).loaded).toBe(1);+ expect(statSync(file!).ino).toBe(written);+ processRun(['160004', '112'], [23, 25]);+ expect(statSync(file!).ino).not.toBe(written);+ expect(processRun(['160004', '112']).before).toEqual([23, 25]);+}));+test('the file holds digests and type ids only: no SQL text, credentials or host', () => withHome(home => {processRun(['160004', '112'], [25, 25]);const text = readFileSync(cacheFiles(home)[0]!, 'utf8');