mirror of
https://github.com/morluto/rea.git
synced 2026-10-27 09:55:46 +00:00
fix(javascript): trace wrapped Electron IPC paths in large bundles (#1874)
Co-authored-by: David <17119984+fengdwx@users.noreply.github.com>
This commit is contained in:
1 parent
d93fbda390
commit
87b9793c53
46 files changed
+3213
-355
No files matched your search
@@ -6,6 +6,8 @@ import { expect, it } from "vitest";
|
||||
import {
|
||||
SEMANTIC_GRAPH_FILE_NODE_CEILING,
|
||||
SEMANTIC_GRAPH_NODE_CEILING,
|
||||
createJavaScriptSemanticGraphProjection,
|
||||
projectJavaScriptSemanticFileSteps,
|
||||
} from "./JavaScriptSemanticGraphBuilder.js";
|
||||
import {
|
||||
addSemanticGraphNode,
|
||||
@@ -905,3 +907,48 @@ it.each(["{}", "unknownRoot", "{ a: null }"])(
|
||||
expect(trace.nodes.filter(({ kind }) => kind === "literal")).toEqual([]);
|
||||
},
|
||||
);
|
||||
|
||||
it("projects and adopts more than the default per-file capacity when explicitly offered", () => {
|
||||
const text = "external;\n".repeat(20_001);
|
||||
const file: JavaScriptArtifactFile = {
|
||||
path: "large.js",
|
||||
container_sha256: SHA256,
|
||||
sha256: SHA256,
|
||||
bytes: Buffer.byteLength(text),
|
||||
inventory_artifact_id: `art_${SHA256}`,
|
||||
kind: "javascript",
|
||||
unpacked: false,
|
||||
text: { included: true, value: text },
|
||||
};
|
||||
const steps = projectJavaScriptSemanticFileSteps(
|
||||
file,
|
||||
analyzeJavaScriptSemantics(text),
|
||||
20_002,
|
||||
);
|
||||
let result = steps.next();
|
||||
while (!result.done) result = steps.next();
|
||||
expect(result.value.nodes).toHaveLength(20_002);
|
||||
expect(result.value.truncated).toBe(false);
|
||||
const projection = createJavaScriptSemanticGraphProjection({
|
||||
totalNodes: 20_010,
|
||||
fileNodes: 20_002,
|
||||
});
|
||||
projection.adoptFileProjection(result.value);
|
||||
expect(projection.remainingFileNodeBudget()).toBe(8);
|
||||
const graph = projection.finish(SHA256, {
|
||||
graph_id: `jag_${"b".repeat(64)}`,
|
||||
nodes: [],
|
||||
});
|
||||
expect(graph.coverage).toMatchObject({
|
||||
truncated: false,
|
||||
omitted_nodes: 0,
|
||||
omitted_relations: 0,
|
||||
});
|
||||
const bounded = createJavaScriptSemanticGraphProjection({
|
||||
totalNodes: 20_001,
|
||||
fileNodes: 20_002,
|
||||
});
|
||||
expect(() => bounded.adoptFileProjection(result.value)).toThrow(
|
||||
"exceed the offered tree capacity",
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user