mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 19:44:30 +00:00
fix(config): prevent RangeError in merged schema cache key generation
Fix merged schema cache key generation for high-cardinality plugin/channel metadata by hashing incrementally instead of serializing one large aggregate string. Includes changelog entry for the user-visible regression fix. Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Co-authored-by: Bill <gsamzn@gmail.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import crypto from "node:crypto";
|
||||
import { CHANNEL_IDS } from "../channels/registry.js";
|
||||
import { VERSION } from "../version.js";
|
||||
import type { ConfigUiHint, ConfigUiHints } from "./schema.hints.js";
|
||||
@@ -322,7 +323,24 @@ function buildMergedSchemaCacheKey(params: {
|
||||
configUiHints: channel.configUiHints ?? null,
|
||||
}))
|
||||
.toSorted((a, b) => a.id.localeCompare(b.id));
|
||||
return JSON.stringify({ plugins, channels });
|
||||
// Build the hash incrementally so we never materialize one giant JSON string.
|
||||
const hash = crypto.createHash("sha256");
|
||||
hash.update('{"plugins":[');
|
||||
plugins.forEach((plugin, index) => {
|
||||
if (index > 0) {
|
||||
hash.update(",");
|
||||
}
|
||||
hash.update(JSON.stringify(plugin));
|
||||
});
|
||||
hash.update('],"channels":[');
|
||||
channels.forEach((channel, index) => {
|
||||
if (index > 0) {
|
||||
hash.update(",");
|
||||
}
|
||||
hash.update(JSON.stringify(channel));
|
||||
});
|
||||
hash.update("]}");
|
||||
return hash.digest("hex");
|
||||
}
|
||||
|
||||
function setMergedSchemaCache(key: string, value: ConfigSchemaResponse): void {
|
||||
|
||||
Reference in New Issue
Block a user