Chrome DevTools for coding agents
feat: Truncate long names by default to 100 characters (#2893)
Dominik Inführ5ddb0a3110c5
diff --git a/docs/tool-reference.md b/docs/tool-reference.mdindex 2524cdbc..5806ccaa 100644--- a/docs/tool-reference.md+++ b/docs/tool-reference.md@@ -519,6 +519,7 @@ in the DevTools Elements panel (if any).**Parameters:**- **filePath** (string) **(required)**: A path to a .heapsnapshot file to read.+- **maxNameLength** (integer) _(optional)_: Maximum length of names before truncation. Defaults to 100.- **pageIdx** (integer) _(optional)_: The zero-based page index. Defaults to 0.- **pageSize** (integer) _(optional)_: The number of contexts to return per page. Defaults to 20.- **retainedSize** (string) _(optional)_: Inclusive range for the dead-field score of a context (e.g. "10KB", "1MB-2MB", "-1MB", or "1MB-"). A single value is treated as a minimum.@@ -557,6 +558,7 @@ in the DevTools Elements panel (if any).- **filePath** (string) **(required)**: A path to a .heapsnapshot file to read.- **id** (number) **(required)**: The ID for the class, obtained from details.- **filterName** (enum: "objectsRetainedByDetachedDomNodes", "objectsRetainedByConsole", "objectsRetainedByEventHandlers", "objectsRetainedByContexts", "sharedNativeContext", "noNativeContext", "attributedToSpecificNativeContext") _(optional)_: An optional filter to apply to the nodes.+- **maxNameLength** (integer) _(optional)_: Maximum length of names before truncation. Defaults to 100.- **objectId** (number) _(optional)_: The object ID (nodeId) of the specific native context to filter by when filterName is attributedToSpecificNativeContext.- **pageIdx** (number) _(optional)_: The page index for pagination.- **pageSize** (number) _(optional)_: The page size for pagination.@@ -585,6 +587,7 @@ in the DevTools Elements panel (if any).- **filePath** (string) **(required)**: A path to a .heapsnapshot file to read.- **nodeId** (number) **(required)**: The node ID to get the dominator chain for.+- **maxNameLength** (integer) _(optional)_: Maximum length of names before truncation. Defaults to 100.---@@ -595,6 +598,7 @@ in the DevTools Elements panel (if any).**Parameters:**- **filePath** (string) **(required)**: A path to a .heapsnapshot file to read.+- **maxNameLength** (integer) _(optional)_: Maximum length of names before truncation. Defaults to 100.- **pageIdx** (number) _(optional)_: The page index for pagination.- **pageSize** (number) _(optional)_: The page size for pagination.@@ -609,6 +613,7 @@ in the DevTools Elements panel (if any).- **filePath** (string) **(required)**: A path to a .heapsnapshot file to read.- **nodeId** (number) **(required)**: The node ID to get outgoing edges for.- **excludePrimitives** (boolean) _(optional)_: Whether to exclude primitive target nodes. Default is true.+- **maxNameLength** (integer) _(optional)_: Maximum length of names before truncation. Defaults to 100.- **pageIdx** (number) _(optional)_: The page index for pagination.- **pageSize** (number) _(optional)_: The page size for pagination.- **retainedSize** (string) _(optional)_: Inclusive retained size range (e.g. "1MB-2MB", "-1MB", or "1MB-") for target nodes. A single value is treated as a minimum. Currently, only the lower bound is applied.@@ -624,6 +629,7 @@ in the DevTools Elements panel (if any).- **filePath** (string) **(required)**: A path to a .heapsnapshot file to read.- **nodeId** (number) **(required)**: The node ID to get object details for.+- **maxNameLength** (integer) _(optional)_: Maximum length of names before truncation. Defaults to 100.---@@ -635,6 +641,7 @@ in the DevTools Elements panel (if any).- **filePath** (string) **(required)**: A path to a .heapsnapshot file to read.- **nodeId** (number) **(required)**: The node ID to get retainers for.+- **maxNameLength** (integer) _(optional)_: Maximum length of names before truncation. Defaults to 100.- **pageIdx** (number) _(optional)_: The page index for pagination.- **pageSize** (number) _(optional)_: The page size for pagination.@@ -649,6 +656,7 @@ in the DevTools Elements panel (if any).- **filePath** (string) **(required)**: A path to a .heapsnapshot file to read.- **nodeId** (number) **(required)**: The node ID to get retaining paths for.- **maxDepth** (number) _(optional)_: The maximum depth to search for retaining paths.+- **maxNameLength** (integer) _(optional)_: Maximum length of names before truncation. Defaults to 100.- **maxNodes** (number) _(optional)_: The maximum number of nodes to return.- **maxSiblings** (number) _(optional)_: The maximum number of siblings to return.@@ -661,6 +669,7 @@ in the DevTools Elements panel (if any).**Parameters:**- **filePath** (string) **(required)**: A path to a .heapsnapshot file to read.+- **maxNameLength** (integer) _(optional)_: Maximum length of names before truncation. Defaults to 100.---@@ -673,6 +682,7 @@ in the DevTools Elements panel (if any).- **filePath** (string) **(required)**: A path to a .heapsnapshot file to read.- **className** (string) _(optional)_: Optional regex or text matching object class name.- **isDetached** (boolean) _(optional)_: Whether to filter for detached DOM nodes.+- **maxNameLength** (integer) _(optional)_: Maximum length of names before truncation. Defaults to 100.- **nodeType** (string) _(optional)_: Optional V8 node type filter (e.g. object, closure, string, array, code).- **pageIdx** (number) _(optional)_: The page index for pagination.- **pageSize** (number) _(optional)_: The page size for pagination.diff --git a/src/McpResponse.ts b/src/McpResponse.tsindex 6223c23c..4b20b89f 100644--- a/src/McpResponse.ts+++ b/src/McpResponse.ts@@ -22,7 +22,9 @@ import {collectRankedContexts,type ContextAnalysisReport,type ContextFilterOptions,+ formatName,HeapSnapshotFormatter,+ type HeapSnapshotFormatOptions,isEdgeLike,isNodeLike,} from './formatters/HeapSnapshotFormatter.js';@@ -81,7 +83,7 @@ interface TraceInsightData {}interface ContextAnalysisOptions- extends PaginationOptions, ContextFilterOptions {}+ extends PaginationOptions, ContextFilterOptions, HeapSnapshotFormatOptions {}export class McpResponse implements Response {#includePages = false;@@ -116,6 +118,7 @@ export class McpResponse implements Response {objectInfo?: DevTools.HeapSnapshotModel.HeapSnapshotModel.ObjectInfo;contextAnalysis?: DevTools.HeapSnapshotModel.HeapSnapshotModel.ContextAnalysisResult;contextAnalysisOptions?: ContextAnalysisOptions;+ formatOptions?: HeapSnapshotFormatOptions;};#networkRequestsOptions?: {include: boolean;@@ -389,6 +392,7 @@ export class McpResponse implements Response {staticData: DevTools.HeapSnapshotModel.HeapSnapshotModel.StaticData | null,nativeContextSizes: DevTools.HeapSnapshotModel.HeapSnapshotModel.NativeContextSizes,retainedByContextSummary: DevTools.HeapSnapshotModel.HeapSnapshotModel.RetainedByContextSummary,+ options?: HeapSnapshotFormatOptions,) {this.#heapSnapshotOptions = {...this.#heapSnapshotOptions,@@ -397,50 +401,57 @@ export class McpResponse implements Response {staticData,nativeContextSizes,retainedByContextSummary,+ formatOptions: options,};}setHeapSnapshotNodes(nodes: DevTools.HeapSnapshotModel.HeapSnapshotModel.ItemsRange,- options?: PaginationOptions,+ options?: PaginationOptions & HeapSnapshotFormatOptions,) {this.#heapSnapshotOptions = {...this.#heapSnapshotOptions,include: true,nodes,pagination: options,+ formatOptions: options,};}setHeapSnapshotDuplicateStrings(duplicateStrings: DuplicateStringGroup[],- options?: PaginationOptions,+ options?: PaginationOptions & HeapSnapshotFormatOptions,) {this.#heapSnapshotOptions = {...this.#heapSnapshotOptions,include: true,duplicateStrings,pagination: options,+ formatOptions: options,};}setHeapSnapshotRetainingPaths(retainingPaths: DevTools.HeapSnapshotModel.HeapSnapshotModel.RetainingPaths,+ options?: HeapSnapshotFormatOptions,) {this.#heapSnapshotOptions = {...this.#heapSnapshotOptions,include: true,retainingPaths,+ formatOptions: options,};}setHeapSnapshotDominators(dominators: DevTools.HeapSnapshotModel.HeapSnapshotModel.DominatorChain,+ options?: HeapSnapshotFormatOptions,) {this.#heapSnapshotOptions = {...this.#heapSnapshotOptions,include: true,dominators,+ formatOptions: options,};}@@ -464,11 +475,13 @@ export class McpResponse implements Response {setHeapSnapshotObjectDetails(objectInfo: DevTools.HeapSnapshotModel.HeapSnapshotModel.ObjectInfo,+ options?: HeapSnapshotFormatOptions,) {this.#heapSnapshotOptions = {...this.#heapSnapshotOptions,include: true,objectInfo,+ formatOptions: options,};}@@ -481,6 +494,7 @@ export class McpResponse implements Response {include: true,contextAnalysis,contextAnalysisOptions: options,+ formatOptions: options,};}@@ -1191,6 +1205,7 @@ Call ${handleDialog(this.#args).name} to handle it before continuing.`);if (this.#heapSnapshotOptions?.include) {response.push('## Heap Snapshot Data');+ const formatOptions = this.#heapSnapshotOptions.formatOptions ?? {};const stats = this.#heapSnapshotOptions.stats;const staticData = this.#heapSnapshotOptions.staticData;if (stats) {@@ -1207,7 +1222,10 @@ Call ${handleDialog(this.#args).name} to handle it before continuing.`);if (nativeContextSizes) {response.push('### Native Contexts');response.push(- HeapSnapshotFormatter.formatNativeContextSizes(nativeContextSizes),+ HeapSnapshotFormatter.formatNativeContextSizes(+ nativeContextSizes,+ formatOptions,+ ),);structuredContent.heapSnapshot = structuredContent.heapSnapshot || {};structuredContent.heapSnapshot.nativeContextSizes = nativeContextSizes;@@ -1277,7 +1295,12 @@ Call ${handleDialog(this.#args).name} to handle it before continuing.`);this.#heapSnapshotOptions.pagination,);- response.push(HeapSnapshotFormatter.formatNodes(paginationData.items));+ response.push(+ HeapSnapshotFormatter.formatNodes(+ paginationData.items,+ formatOptions,+ ),+ );structuredContent.pagination = paginationData.pagination;response.push(...paginationData.info);@@ -1291,7 +1314,9 @@ Call ${handleDialog(this.#args).name} to handle it before continuing.`);if (paths.length === 0) {response.push('No retaining paths found.');} else {- response.push(HeapSnapshotFormatter.formatRetainingPaths(paths));+ response.push(+ HeapSnapshotFormatter.formatRetainingPaths(paths, formatOptions),+ );}const reached = Object.entries(limitsReached).filter(([, hit]) => hit)@@ -1310,7 +1335,9 @@ Call ${handleDialog(this.#args).name} to handle it before continuing.`);if (dominators.length === 0) {response.push('No dominators found.');} else {- response.push(HeapSnapshotFormatter.formatDominators(dominators));+ response.push(+ HeapSnapshotFormatter.formatDominators(dominators, formatOptions),+ );}structuredContent.heapSnapshotDominators = dominators;}@@ -1347,6 +1374,7 @@ Call ${handleDialog(this.#args).name} to handle it before continuing.`);const formatted = HeapSnapshotFormatter.formatDuplicateStrings(paginationData.items,+ formatOptions,);response.push(formatted);@@ -1355,11 +1383,18 @@ Call ${handleDialog(this.#args).name} to handle it before continuing.`);const objectInfo = this.#heapSnapshotOptions.objectInfo;if (objectInfo) {response.push('### Object Details');- response.push(- compactEncode- ? compactEncode(objectInfo)- : HeapSnapshotFormatter.formatObjectInfo(objectInfo),- );+ if (compactEncode) {+ response.push(+ compactEncode({+ ...objectInfo,+ name: formatName(objectInfo.name, formatOptions),+ }),+ );+ } else {+ response.push(+ HeapSnapshotFormatter.formatObjectInfo(objectInfo, formatOptions),+ );+ }structuredContent.heapSnapshotObjectDetails = objectInfo;}const contextAnalysis = this.#heapSnapshotOptions.contextAnalysis;@@ -1385,7 +1420,10 @@ Call ${handleDialog(this.#args).name} to handle it before continuing.`);response.push(compactEncode? compactEncode(report)- : HeapSnapshotFormatter.formatContextAnalysis(report),+ : HeapSnapshotFormatter.formatContextAnalysis(+ report,+ formatOptions,+ ),);structuredContent.heapSnapshotContextAnalysis = report;}diff --git a/src/config/cli-options.ts b/src/config/cli-options.tsindex c3834395..30ef5e85 100644--- a/src/config/cli-options.ts+++ b/src/config/cli-options.ts@@ -52,6 +52,13 @@ export const commands: Commands = {'Only return contexts declared by the scope with this ScopeInfo node id, as reported in the scope header of a previous call.',required: false,},+ maxNameLength: {+ name: 'maxNameLength',+ type: 'integer',+ description:+ 'Maximum length of names before truncation. Defaults to 100.',+ required: false,+ },pageIdx: {name: 'pageIdx',type: 'integer',@@ -535,6 +542,13 @@ export const commands: Commands = {'The object ID (nodeId) of the specific native context to filter by when filterName is attributedToSpecificNativeContext.',required: false,},+ maxNameLength: {+ name: 'maxNameLength',+ type: 'integer',+ description:+ 'Maximum length of names before truncation. Defaults to 100.',+ required: false,+ },pageIdx: {name: 'pageIdx',type: 'number',@@ -613,6 +627,13 @@ export const commands: Commands = {description: 'The node ID to get the dominator chain for.',required: true,},+ maxNameLength: {+ name: 'maxNameLength',+ type: 'integer',+ description:+ 'Maximum length of names before truncation. Defaults to 100.',+ required: false,+ },},},get_heapsnapshot_duplicate_strings: {@@ -638,6 +659,13 @@ export const commands: Commands = {description: 'The page size for pagination.',required: false,},+ maxNameLength: {+ name: 'maxNameLength',+ type: 'integer',+ description:+ 'Maximum length of names before truncation. Defaults to 100.',+ required: false,+ },},},get_heapsnapshot_edges: {@@ -678,6 +706,13 @@ export const commands: Commands = {'Whether to exclude primitive target nodes. Default is true.',required: false,},+ maxNameLength: {+ name: 'maxNameLength',+ type: 'integer',+ description:+ 'Maximum length of names before truncation. Defaults to 100.',+ required: false,+ },pageIdx: {name: 'pageIdx',type: 'number',@@ -709,6 +744,13 @@ export const commands: Commands = {description: 'The node ID to get object details for.',required: true,},+ maxNameLength: {+ name: 'maxNameLength',+ type: 'integer',+ description:+ 'Maximum length of names before truncation. Defaults to 100.',+ required: false,+ },},},get_heapsnapshot_retainers: {@@ -728,6 +770,13 @@ export const commands: Commands = {description: 'The node ID to get retainers for.',required: true,},+ maxNameLength: {+ name: 'maxNameLength',+ type: 'integer',+ description:+ 'Maximum length of names before truncation. Defaults to 100.',+ required: false,+ },pageIdx: {name: 'pageIdx',type: 'number',@@ -777,6 +826,13 @@ export const commands: Commands = {description: 'The maximum number of siblings to return.',required: false,},+ maxNameLength: {+ name: 'maxNameLength',+ type: 'integer',+ description:+ 'Maximum length of names before truncation. Defaults to 100.',+ required: false,+ },},},get_heapsnapshot_summary: {@@ -790,6 +846,13 @@ export const commands: Commands = {description: 'A path to a .heapsnapshot file to read.',required: true,},+ maxNameLength: {+ name: 'maxNameLength',+ type: 'integer',+ description:+ 'Maximum length of names before truncation. Defaults to 100.',+ required: false,+ },},},get_network_request: {@@ -1397,6 +1460,13 @@ export const commands: Commands = {description: 'The page size for pagination.',required: false,},+ maxNameLength: {+ name: 'maxNameLength',+ type: 'integer',+ description:+ 'Maximum length of names before truncation. Defaults to 100.',+ required: false,+ },},},reload_extension: {diff --git a/src/formatters/HeapSnapshotFormatter.ts b/src/formatters/HeapSnapshotFormatter.tsindex 60f31d82..459a808b 100644--- a/src/formatters/HeapSnapshotFormatter.ts+++ b/src/formatters/HeapSnapshotFormatter.ts@@ -16,6 +16,39 @@ import {stableIdSymbol} from '../utils/id.js';const {formatBytesToKb} = DevTools.I18n.ByteUtilities;+export const MAX_NAME_LENGTH = 100;++export interface HeapSnapshotFormatOptions {+ /**+ * Values longer than this are truncated. Defaults to `MAX_NAME_LENGTH`. Pass+ * a large value to get untruncated values.+ */+ maxNameLength?: number;+}++/**+ * Renders a name for single-line output: the name is truncated to+ * `maxNameLength` and line breaks are always escaped.+ */+export function formatName(+ name: string,+ options: HeapSnapshotFormatOptions,+): string {+ return truncateValue(name, options.maxNameLength)+ .replaceAll('\r', '\\r')+ .replaceAll('\n', '\\n');+}++/**+ * Truncates `value` to `maxLength`, appending an ellipsis if it was cut off.+ */+function truncateValue(value: string, maxLength = MAX_NAME_LENGTH): string {+ if (value.length <= maxLength) {+ return value;+ }+ return value.slice(0, maxLength) + '...';+}+export interface FormattedSnapshotEntry {className: string;id?: number;@@ -111,6 +144,7 @@ export class HeapSnapshotFormatter {| DevTools.HeapSnapshotModel.HeapSnapshotModel.Node| DevTools.HeapSnapshotModel.HeapSnapshotModel.Edge>,+ options: HeapSnapshotFormatOptions,): string {const lines: string[] = [];@@ -126,11 +160,11 @@ export class HeapSnapshotFormatter {for (const item of items) {if (isNodeLike(item)) {lines.push(- `${item.id},${item.name},${item.type},${item.distance},${formatBytesToKb(item.selfSize)},${formatBytesToKb(item.retainedSize)}`,+ `${item.id},${formatName(item.name, options)},${item.type},${item.distance},${formatBytesToKb(item.selfSize)},${formatBytesToKb(item.retainedSize)}`,);} else if (isEdgeLike(item)) {lines.push(- `${item.name},${item.type},${item.node.id},${item.node.name},${formatBytesToKb(item.node.selfSize)},${formatBytesToKb(item.node.retainedSize)}`,+ `${formatName(item.name, options)},${item.type},${item.node.id},${formatName(item.node.name, options)},${formatBytesToKb(item.node.selfSize)},${formatBytesToKb(item.node.retainedSize)}`,);}}@@ -140,6 +174,7 @@ export class HeapSnapshotFormatter {static formatRetainingPaths(retainingPaths: readonly DevTools.HeapSnapshotModel.HeapSnapshotModel.RetainingEdge[],+ options: HeapSnapshotFormatOptions,): string {const lines: string[] = [];@@ -149,7 +184,7 @@ export class HeapSnapshotFormatter {) {const indent = ' '.repeat(depth);lines.push(- `${indent}<- @${edge.nodeId} ${edge.nodeName} via ${edge.edgeType} ${edge.edgeName} (distance: ${edge.distance})`,+ `${indent}<- @${edge.nodeId} ${formatName(edge.nodeName, options)} via ${edge.edgeType} ${formatName(edge.edgeName, options)} (distance: ${edge.distance})`,);for (const child of edge.children) {formatEdge(child, depth + 1);@@ -165,12 +200,13 @@ export class HeapSnapshotFormatter {static formatDominators(dominators: DevTools.HeapSnapshotModel.HeapSnapshotModel.DominatorChain,+ options: HeapSnapshotFormatOptions,): string {const lines: string[] = [];lines.push('nodeId,nodeName,selfSize,retainedSize');for (const node of dominators) {lines.push(- `${node.nodeId},${node.nodeName},${formatBytesToKb(node.selfSize)},${formatBytesToKb(node.retainedSize)}`,+ `${node.nodeId},${formatName(node.nodeName, options)},${formatBytesToKb(node.selfSize)},${formatBytesToKb(node.retainedSize)}`,);}return lines.join('\n');@@ -178,14 +214,16 @@ export class HeapSnapshotFormatter {static formatDuplicateStrings(groups: readonly DuplicateStringGroup[],+ options: HeapSnapshotFormatOptions,): string {const lines: string[] = [];lines.push('value,count,totalSelfSize,totalRetainedSize,truncated,nodeIds');for (const group of groups) {const nodeIds = group.nodes.map(n => `@${n.id}`).join(' ');const truncated = group.truncated ?? false;+ const displayValue = truncateValue(group.value, options.maxNameLength);lines.push(- `${JSON.stringify(group.value)},${group.count},${formatBytesToKb(group.totalSelfSize)},${formatBytesToKb(group.totalRetainedSize)},${truncated},${nodeIds}`,+ `${JSON.stringify(displayValue)},${group.count},${formatBytesToKb(group.totalSelfSize)},${formatBytesToKb(group.totalRetainedSize)},${truncated},${nodeIds}`,);}return lines.join('\n');@@ -193,6 +231,7 @@ export class HeapSnapshotFormatter {static formatNativeContextSizes(sizes: DevTools.HeapSnapshotModel.HeapSnapshotModel.NativeContextSizes,+ options: HeapSnapshotFormatOptions,): string {const lines: string[] = [];lines.push('nodeId,nodeName,selfSize,retainedSize,attributedSize');@@ -201,7 +240,7 @@ export class HeapSnapshotFormatter {);for (const nc of sortedContexts) {lines.push(- `${nc.nodeId},${nc.nodeName},${formatBytesToKb(nc.selfSize)},${formatBytesToKb(nc.retainedSize)},${formatBytesToKb(nc.attributedSize)}`,+ `${nc.nodeId},${formatName(nc.nodeName, options)},${formatBytesToKb(nc.selfSize)},${formatBytesToKb(nc.retainedSize)},${formatBytesToKb(nc.attributedSize)}`,);}lines.push(`Shared Size: ${formatBytesToKb(sizes.sharedSize)}`);@@ -313,10 +352,11 @@ export class HeapSnapshotFormatter {static formatObjectInfo(info: DevTools.HeapSnapshotModel.HeapSnapshotModel.ObjectInfo,+ options: HeapSnapshotFormatOptions,): string {const lines = [`id: @${info.id}`,- `name: ${info.name}`,+ `name: ${formatName(info.name, options)}`,`type: ${info.type}`,`detachedness: ${formatDOMLinkState(info.detachedness)}`,`selfSize: ${formatBytesToKb(info.selfSize)}`,@@ -328,7 +368,10 @@ export class HeapSnapshotFormatter {return lines.join('\n');}- static formatContextAnalysis(report: ContextAnalysisReport): string {+ static formatContextAnalysis(+ report: ContextAnalysisReport,+ options: HeapSnapshotFormatOptions,+ ): string {const lines: string[] = [];if (report.contexts.length === 0) {@@ -340,12 +383,12 @@ export class HeapSnapshotFormatter {lines.push('');}lines.push(- `#### Context @${context.contextNodeId} in \`${formatScopeName(scope)}\` — ${formatBytesToKb(context.deadFieldsRetainedSizeSum)}`,+ `#### Context @${context.contextNodeId} in \`${formatScopeName(scope, options)}\` — ${formatBytesToKb(context.deadFieldsRetainedSizeSum)}`,`Script @${scope.scriptNodeId}, ScopeInfo @${scope.scopeInfoNodeId}, offsets ${scope.scopeStart}-${scope.scopeEnd}, ${formatCount(scope.contextFieldCount, 'context field')}`,);for (const field of context.deadFields) {lines.push(- `- \`${field.name}\` (${field.valueName} @${field.valueNodeId}) — ${formatBytesToKb(field.retainedSize)}`,+ `- \`${formatName(field.name, options)}\` (${formatName(field.valueName, options)} @${field.valueNodeId}) — ${formatBytesToKb(field.retainedSize)}`,);}}@@ -353,8 +396,11 @@ export class HeapSnapshotFormatter {if (report.scriptsWithoutScopes.length > 0) {lines.push('', 'Scripts without scope metadata could not be analyzed:');for (const script of report.scriptsWithoutScopes) {+ const scriptName = script.scriptName+ ? formatName(script.scriptName, options)+ : `script @${script.scriptNodeId}`;lines.push(- `- \`${script.scriptName || `script @${script.scriptNodeId}`}\` (@${script.scriptNodeId}) — ${formatCount(script.contextCount, 'context')}`,+ `- \`${scriptName}\` (@${script.scriptNodeId}) — ${formatCount(script.contextCount, 'context')}`,);}}@@ -369,9 +415,14 @@ function formatCount(count: number, singular: string): string {function formatScopeName(scope: DevTools.HeapSnapshotModel.HeapSnapshotModel.ScopeAnalysis,+ options: HeapSnapshotFormatOptions,): string {- const scriptName = scope.scriptName || `script @${scope.scriptNodeId}`;- return scope.scopeName ? `${scope.scopeName} (${scriptName})` : scriptName;+ const scriptName = scope.scriptName+ ? formatName(scope.scriptName, options)+ : `script @${scope.scriptNodeId}`;+ return scope.scopeName+ ? `${formatName(scope.scopeName, options)} (${scriptName})`+ : scriptName;}function formatDOMLinkState(diff --git a/src/telemetry/tool_call_metrics.json b/src/telemetry/tool_call_metrics.jsonindex 8bb87210..57bbeba5 100644--- a/src/telemetry/tool_call_metrics.json+++ b/src/telemetry/tool_call_metrics.json@@ -841,6 +841,10 @@{"name": "object_id","argType": "number"+ },+ {+ "name": "max_name_length",+ "argType": "number"}]},@@ -887,6 +891,10 @@{"name": "page_size","argType": "number"+ },+ {+ "name": "max_name_length",+ "argType": "number"}]},@@ -896,6 +904,10 @@{"name": "file_path_length","argType": "number"+ },+ {+ "name": "max_name_length",+ "argType": "number"}]},@@ -943,6 +955,10 @@{"name": "max_siblings","argType": "number"+ },+ {+ "name": "max_name_length",+ "argType": "number"}]},@@ -981,6 +997,10 @@{"name": "retained_size_length","argType": "number"+ },+ {+ "name": "max_name_length",+ "argType": "number"}]},@@ -994,6 +1014,10 @@{"name": "node_id","argType": "number"+ },+ {+ "name": "max_name_length",+ "argType": "number"}]},@@ -1060,6 +1084,10 @@{"name": "page_size","argType": "number"+ },+ {+ "name": "max_name_length",+ "argType": "number"}]},@@ -1073,6 +1101,10 @@{"name": "node_id","argType": "number"+ },+ {+ "name": "max_name_length",+ "argType": "number"}]},@@ -1186,6 +1218,10 @@{"name": "self_size_length","argType": "number"+ },+ {+ "name": "max_name_length",+ "argType": "number"}]},@@ -1228,6 +1264,10 @@{"name": "page_size","argType": "number"+ },+ {+ "name": "max_name_length",+ "argType": "number"}]},diff --git a/src/tools/ToolDefinition.ts b/src/tools/ToolDefinition.tsindex 99859c54..e51ad82f 100644--- a/src/tools/ToolDefinition.ts+++ b/src/tools/ToolDefinition.ts@@ -16,7 +16,10 @@ import type {import type {McpPage} from '../McpPage.js';import type {DevToolsCommentBridge} from '../devtools/DevToolsCommentBridge.js';import type {CssFormatterOptions} from '../formatters/CssFormatter.js';-import type {ContextFilterOptions} from '../formatters/HeapSnapshotFormatter.js';+import type {+ ContextFilterOptions,+ HeapSnapshotFormatOptions,+} from '../formatters/HeapSnapshotFormatter.js';import {zod} from '../third_party/index.js';import type {Dialog,@@ -164,20 +167,23 @@ export interface Response {staticData: DevTools.HeapSnapshotModel.HeapSnapshotModel.StaticData | null,nativeContextSizes: DevTools.HeapSnapshotModel.HeapSnapshotModel.NativeContextSizes,retainedByContextSummary: DevTools.HeapSnapshotModel.HeapSnapshotModel.RetainedByContextSummary,+ options?: HeapSnapshotFormatOptions,): void;setHeapSnapshotNodes(nodes: DevTools.HeapSnapshotModel.HeapSnapshotModel.ItemsRange,- options?: PaginationOptions,+ options?: PaginationOptions & HeapSnapshotFormatOptions,): void;setHeapSnapshotDuplicateStrings(duplicateStrings: DuplicateStringGroup[],- options?: PaginationOptions,+ options?: PaginationOptions & HeapSnapshotFormatOptions,): void;setHeapSnapshotRetainingPaths(retainingPaths: DevTools.HeapSnapshotModel.HeapSnapshotModel.RetainingPaths,+ options?: HeapSnapshotFormatOptions,): void;setHeapSnapshotDominators(dominators: DevTools.HeapSnapshotModel.HeapSnapshotModel.DominatorChain,+ options?: HeapSnapshotFormatOptions,): void;setHeapSnapshotClassDiffs(classDiffs: HeapSnapshotClassDiff[]): void;setHeapSnapshotDetailedClassDiff(@@ -185,10 +191,13 @@ export interface Response {): void;setHeapSnapshotObjectDetails(objectInfo: DevTools.HeapSnapshotModel.HeapSnapshotModel.ObjectInfo,+ options?: HeapSnapshotFormatOptions,): void;setHeapSnapshotContextAnalysis(analysis: DevTools.HeapSnapshotModel.HeapSnapshotModel.ContextAnalysisResult,- options?: PaginationOptions & ContextFilterOptions,+ options?: PaginationOptions &+ ContextFilterOptions &+ HeapSnapshotFormatOptions,): void;setIncludePages(value: boolean): void;setIncludeNetworkRequests(diff --git a/src/tools/memory.ts b/src/tools/memory.tsindex a9e75a8f..404267f4 100644--- a/src/tools/memory.ts+++ b/src/tools/memory.ts@@ -4,6 +4,7 @@* SPDX-License-Identifier: Apache-2.0*/+import {MAX_NAME_LENGTH} from '../formatters/HeapSnapshotFormatter.js';import {zod} from '../third_party/index.js';import {byteSizeRangeSchema} from '../utils/bytes.js';@@ -20,6 +21,15 @@ const HEAP_SNAPSHOT_FILTERS: readonly [string, ...string[]] = ['attributedToSpecificNativeContext',];+const maxNameLengthSchema = zod+ .number()+ .int()+ .min(1)+ .optional()+ .describe(+ `Maximum length of names before truncation. Defaults to ${MAX_NAME_LENGTH}.`,+ );+export const takeHeapSnapshot = definePageTool(() => ({name: 'take_heapsnapshot',description: `Capture a heap snapshot of the target page. Use to analyze the memory distribution of JavaScript objects and debug memory leaks.`,@@ -62,6 +72,7 @@ export const getHeapSnapshotSummary = defineTool(() => ({},schema: {filePath: zod.string().describe('A path to a .heapsnapshot file to read.'),+ maxNameLength: maxNameLengthSchema,},blockedByDialog: false,verifyFilesSchema: {@@ -85,6 +96,9 @@ export const getHeapSnapshotSummary = defineTool(() => ({staticData,nativeContextSizes,retainedByContextSummary,+ {+ maxNameLength: request.params.maxNameLength,+ },);},}));@@ -159,6 +173,7 @@ export const getHeapSnapshotClassNodes = defineTool(() => ({.describe('The object ID (nodeId) of the specific native context to filter by when filterName is attributedToSpecificNativeContext.',),+ maxNameLength: maxNameLengthSchema,pageIdx: zod.number().optional().describe('The page index for pagination.'),pageSize: zod.number().optional().describe('The page size for pagination.'),},@@ -177,6 +192,7 @@ export const getHeapSnapshotClassNodes = defineTool(() => ({response.setHeapSnapshotNodes(nodes, {pageIdx: request.params.pageIdx,pageSize: request.params.pageSize,+ maxNameLength: request.params.maxNameLength,});},}));@@ -197,6 +213,7 @@ export const getHeapSnapshotRetainers = defineTool(() => ({schema: {filePath: zod.string().describe('A path to a .heapsnapshot file to read.'),nodeId: zod.number().describe('The node ID to get retainers for.'),+ maxNameLength: maxNameLengthSchema,pageIdx: zod.number().optional().describe('The page index for pagination.'),pageSize: zod.number().optional().describe('The page size for pagination.'),},@@ -209,6 +226,7 @@ export const getHeapSnapshotRetainers = defineTool(() => ({response.setHeapSnapshotNodes(retainers, {pageIdx: request.params.pageIdx,pageSize: request.params.pageSize,+ maxNameLength: request.params.maxNameLength,});},}));@@ -272,6 +290,7 @@ export const getHeapSnapshotRetainingPaths = defineTool(() => ({.number().optional().describe('The maximum number of siblings to return.'),+ maxNameLength: maxNameLengthSchema,},handler: async (request, response, context) => {const retainingPaths = await context.getHeapSnapshotRetainingPaths(@@ -282,7 +301,9 @@ export const getHeapSnapshotRetainingPaths = defineTool(() => ({request.params.maxSiblings,);- response.setHeapSnapshotRetainingPaths(retainingPaths);+ response.setHeapSnapshotRetainingPaths(retainingPaths, {+ maxNameLength: request.params.maxNameLength,+ });},}));@@ -313,6 +334,7 @@ export const getHeapSnapshotEdges = defineTool(() => ({.boolean().optional().describe('Whether to exclude primitive target nodes. Default is true.'),+ maxNameLength: maxNameLengthSchema,pageIdx: zod.number().optional().describe('The page index for pagination.'),pageSize: zod.number().optional().describe('The page size for pagination.'),},@@ -331,6 +353,7 @@ export const getHeapSnapshotEdges = defineTool(() => ({response.setHeapSnapshotNodes(edges, {pageIdx: request.params.pageIdx,pageSize: request.params.pageSize,+ maxNameLength: request.params.maxNameLength,});},}));@@ -353,6 +376,7 @@ export const getHeapSnapshotDominators = defineTool(() => ({nodeId: zod.number().describe('The node ID to get the dominator chain for.'),+ maxNameLength: maxNameLengthSchema,},handler: async (request, response, context) => {const dominators = await context.getHeapSnapshotDominators(@@ -360,7 +384,9 @@ export const getHeapSnapshotDominators = defineTool(() => ({request.params.nodeId,);- response.setHeapSnapshotDominators(dominators);+ response.setHeapSnapshotDominators(dominators, {+ maxNameLength: request.params.maxNameLength,+ });},}));@@ -427,6 +453,7 @@ export const getHeapSnapshotDuplicateStrings = defineTool(() => ({filePath: zod.string().describe('A path to a .heapsnapshot file to read.'),pageIdx: zod.number().optional().describe('The page index for pagination.'),pageSize: zod.number().optional().describe('The page size for pagination.'),+ maxNameLength: maxNameLengthSchema,},handler: async (request, response, context) => {const duplicateStrings = await context.getHeapSnapshotDuplicateStrings(@@ -436,6 +463,7 @@ export const getHeapSnapshotDuplicateStrings = defineTool(() => ({response.setHeapSnapshotDuplicateStrings(duplicateStrings, {pageIdx: request.params.pageIdx,pageSize: request.params.pageSize,+ maxNameLength: request.params.maxNameLength,});},}));@@ -456,6 +484,7 @@ export const getHeapSnapshotObjectDetails = defineTool(() => ({schema: {filePath: zod.string().describe('A path to a .heapsnapshot file to read.'),nodeId: zod.number().describe('The node ID to get object details for.'),+ maxNameLength: maxNameLengthSchema,},handler: async (request, response, context) => {const objectInfo = await context.getHeapSnapshotObjectDetails(@@ -463,7 +492,9 @@ export const getHeapSnapshotObjectDetails = defineTool(() => ({request.params.nodeId,);- response.setHeapSnapshotObjectDetails(objectInfo);+ response.setHeapSnapshotObjectDetails(objectInfo, {+ maxNameLength: request.params.maxNameLength,+ });},}));@@ -510,6 +541,7 @@ export const queryHeapSnapshotObjects = defineTool(() => ({.describe('Sort order for results. Default is retainedSize.'),pageIdx: zod.number().optional().describe('The page index for pagination.'),pageSize: zod.number().optional().describe('The page size for pagination.'),+ maxNameLength: maxNameLengthSchema,},handler: async (request, response, context) => {const range = await context.queryHeapSnapshotObjects(@@ -530,6 +562,7 @@ export const queryHeapSnapshotObjects = defineTool(() => ({response.setHeapSnapshotNodes(range, {pageIdx: request.params.pageIdx,pageSize: request.params.pageSize,+ maxNameLength: request.params.maxNameLength,});},}));@@ -559,6 +592,7 @@ export const analyzeHeapSnapshotContexts = defineTool(() => ({.describe('Only return contexts declared by the scope with this ScopeInfo node id, as reported in the scope header of a previous call.',),+ maxNameLength: maxNameLengthSchema,pageIdx: zod.number().int()@@ -580,6 +614,7 @@ export const analyzeHeapSnapshotContexts = defineTool(() => ({response.setHeapSnapshotContextAnalysis(analysis, {retainedSize: request.params.retainedSize,scopeInfoNodeId: request.params.scopeInfoNodeId,+ maxNameLength: request.params.maxNameLength,pageIdx: request.params.pageIdx,pageSize: request.params.pageSize,});diff --git a/tests/McpResponse.test.ts b/tests/McpResponse.test.tsindex 13365128..34b26635 100644--- a/tests/McpResponse.test.ts+++ b/tests/McpResponse.test.ts@@ -1581,6 +1581,23 @@ describe('McpResponse heap snapshot formatting', () => {assert.ok(objectText.includes('name: Object'));});+ it('truncates object details name in compact format', async () => {+ const context = createMockMcpContext();+ const toonResponse = new McpResponse(createMockParsedArguments());+ const longNameObjectInfo = {+ ...createMockObjectInfo(),+ name: 'Object_' + 'x'.repeat(150),+ };+ toonResponse.setHeapSnapshotObjectDetails(longNameObjectInfo, {+ maxNameLength: 10,+ });++ const toonResult = await toonResponse.handle(context, 'toon');+ const toonText = getTextContent(toonResult.content[0]);+ assert.ok(toonText.includes('### Object Details'));+ assert.ok(toonText.includes('Object_xxx...'));+ });+it('renders the context field usage section for the filtered contexts', async () => {const response = new McpResponse(createMockParsedArguments());response.setHeapSnapshotContextAnalysis(createMockContextAnalysisResult(), {diff --git a/tests/formatters/HeapSnapshotFormatter.test.ts b/tests/formatters/HeapSnapshotFormatter.test.tsindex 0fab1e49..89305689 100644--- a/tests/formatters/HeapSnapshotFormatter.test.ts+++ b/tests/formatters/HeapSnapshotFormatter.test.ts@@ -11,7 +11,9 @@ import {describe, it, before, after} from 'node:test';import {collectRankedContexts,type ContextAnalysisReport,+ formatName,HeapSnapshotFormatter,+ MAX_NAME_LENGTH,} from '../../src/formatters/HeapSnapshotFormatter.js';import {HeapSnapshotManager} from '../../src/processors/HeapSnapshotManager.js';import {DevTools} from '../../src/third_party/index.js';@@ -55,6 +57,32 @@ describe('HeapSnapshotFormatter', () => {} as unknown as DevTools.HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo,};+ describe('formatName', () => {+ it('returns short name unchanged', () => {+ assert.strictEqual(formatName('shortName', {}), 'shortName');+ });++ it('truncates name exceeding MAX_NAME_LENGTH', () => {+ const longName = 'a'.repeat(150);+ const expected = 'a'.repeat(MAX_NAME_LENGTH) + '...';+ assert.strictEqual(formatName(longName, {}), expected);+ });++ it('escapes newlines in name', () => {+ assert.strictEqual(+ formatName('first\r\nsecond\nthird\rfourth', {}),+ 'first\\r\\nsecond\\nthird\\rfourth',+ );+ });++ it('respects a custom maxNameLength', () => {+ assert.strictEqual(+ formatName('abcdefghij', {maxNameLength: 5}),+ 'abcde...',+ );+ });+ });+describe('toString', () => {it('formats data as CSV and sorts by retained size', t => {const formatter = new HeapSnapshotFormatter(mockAggregates);@@ -129,7 +157,7 @@ describe('HeapSnapshotFormatter', () => {},];- const result = HeapSnapshotFormatter.formatNodes(mockEdges);+ const result = HeapSnapshotFormatter.formatNodes(mockEdges, {});const expected = ['name,type,nodeId,nodeName,selfSize,retainedSize','edge1,property,1,NodeA,0.0 kB,0.0 kB',@@ -254,8 +282,10 @@ describe('HeapSnapshotFormatter', () => {},] as unknown as DevTools.HeapSnapshotModel.HeapSnapshotModel.RetainingEdge[];- const result =- HeapSnapshotFormatter.formatRetainingPaths(mockRetainingPaths);+ const result = HeapSnapshotFormatter.formatRetainingPaths(+ mockRetainingPaths,+ {},+ );const expected = ['<- @10 ClassA via property foo (distance: 2)',' <- @20 ClassB via element bar (distance: 1)',@@ -285,7 +315,7 @@ describe('HeapSnapshotFormatter', () => {},];- const result = HeapSnapshotFormatter.formatDominators(mockDominators);+ const result = HeapSnapshotFormatter.formatDominators(mockDominators, {});const expected = ['nodeId,nodeName,selfSize,retainedSize',`10,ClassA,${formatBytesToKb(100)},${formatBytesToKb(1000)}`,@@ -298,7 +328,7 @@ describe('HeapSnapshotFormatter', () => {it('formats empty dominator chain correctly', () => {const mockDominators: DevTools.HeapSnapshotModel.HeapSnapshotModel.DominatorChain =[];- const result = HeapSnapshotFormatter.formatDominators(mockDominators);+ const result = HeapSnapshotFormatter.formatDominators(mockDominators, {});const expected = 'nodeId,nodeName,selfSize,retainedSize';assert.strictEqual(result, expected);});@@ -330,7 +360,10 @@ describe('HeapSnapshotFormatter', () => {noAttributionSize: 400,};- const result = HeapSnapshotFormatter.formatNativeContextSizes(mockSizes);+ const result = HeapSnapshotFormatter.formatNativeContextSizes(+ mockSizes,+ {},+ );const expected = ['nodeId,nodeName,selfSize,retainedSize,attributedSize',`20,system / NativeContext / https://example.com,${formatBytesToKb(200)},${formatBytesToKb(5000)},${formatBytesToKb(2000)}`,@@ -343,6 +376,62 @@ describe('HeapSnapshotFormatter', () => {});});+ describe('formatDuplicateStrings', () => {+ it('truncates long duplicate string values without changing the truncated flag', () => {+ const longString = 'str_' + 's'.repeat(150);+ const mockGroups: DevTools.HeapSnapshotModel.HeapSnapshotModel.DuplicateStringGroup[] =+ [+ {+ value: longString,+ count: 2,+ totalSelfSize: 200,+ totalRetainedSize: 200,+ nodes: [+ {id: 1, selfSize: 100, retainedSize: 100, distance: 1},+ {id: 2, selfSize: 100, retainedSize: 100, distance: 1},+ ],+ },+ ];++ const result = HeapSnapshotFormatter.formatDuplicateStrings(+ mockGroups,+ {},+ );+ const expectedValue = JSON.stringify('str_' + 's'.repeat(96) + '...');+ const expected = [+ 'value,count,totalSelfSize,totalRetainedSize,truncated,nodeIds',+ `${expectedValue},2,${formatBytesToKb(200)},${formatBytesToKb(200)},false,@1 @2`,+ ].join('\n');++ assert.strictEqual(result, expected);+ });++ it('reports values truncated by the snapshot itself', () => {+ const mockGroups: DevTools.HeapSnapshotModel.HeapSnapshotModel.DuplicateStringGroup[] =+ [+ {+ value: 'short string',+ count: 2,+ totalSelfSize: 20,+ totalRetainedSize: 20,+ truncated: true,+ nodes: [{id: 1, selfSize: 10, retainedSize: 10, distance: 1}],+ },+ ];++ const result = HeapSnapshotFormatter.formatDuplicateStrings(+ mockGroups,+ {},+ );+ const expected = [+ 'value,count,totalSelfSize,totalRetainedSize,truncated,nodeIds',+ `"short string",2,${formatBytesToKb(20)},${formatBytesToKb(20)},true,@1`,+ ].join('\n');++ assert.strictEqual(result, expected);+ });+ });+describe('formatRetainedByContextSummary', () => {it('formats retained by context summary correctly', () => {const mockSummary = {@@ -425,7 +514,7 @@ describe('HeapSnapshotFormatter', () => {it('formats native context sizes from fixture', async t => {const sizes = await manager.getNativeContextSizes(examplePath);t.assert.snapshot(- HeapSnapshotFormatter.formatNativeContextSizes(sizes),+ HeapSnapshotFormatter.formatNativeContextSizes(sizes, {}),);});});@@ -443,7 +532,7 @@ describe('HeapSnapshotFormatter', () => {it('formats class nodes with default options', async t => {await manager.getAggregates(examplePath);const nodes = await manager.getNodesById(examplePath, 19);- t.assert.snapshot(HeapSnapshotFormatter.formatNodes(nodes.items));+ t.assert.snapshot(HeapSnapshotFormatter.formatNodes(nodes.items, {}));});it('formats class nodes with objectsRetainedByContexts filterName', async t => {@@ -464,21 +553,25 @@ describe('HeapSnapshotFormatter', () => {id,'objectsRetainedByContexts',);- t.assert.snapshot(HeapSnapshotFormatter.formatNodes(nodes.items));+ t.assert.snapshot(HeapSnapshotFormatter.formatNodes(nodes.items, {}));});});describe('formatNodes with retainers', () => {it('formats retainers for a valid nodeId', async t => {const retainers = await manager.getRetainers(examplePath, 25341);- t.assert.snapshot(HeapSnapshotFormatter.formatNodes(retainers.items));+ t.assert.snapshot(+ HeapSnapshotFormatter.formatNodes(retainers.items, {}),+ );});});describe('formatObjectInfo', () => {it('formats object details for a valid nodeId', async t => {const objectInfo = await manager.getObjectInfo(examplePath, 25341);- t.assert.snapshot(HeapSnapshotFormatter.formatObjectInfo(objectInfo));+ t.assert.snapshot(+ HeapSnapshotFormatter.formatObjectInfo(objectInfo, {}),+ );});});@@ -489,7 +582,7 @@ describe('HeapSnapshotFormatter', () => {45901,);t.assert.snapshot(- HeapSnapshotFormatter.formatRetainingPaths(retainingPaths.paths),+ HeapSnapshotFormatter.formatRetainingPaths(retainingPaths.paths, {}),);});@@ -507,13 +600,13 @@ describe('HeapSnapshotFormatter', () => {describe('formatNodes with edges', () => {it('formats outgoing edges for a valid nodeId', async t => {const edges = await manager.getEdges(examplePath, 25341);- t.assert.snapshot(HeapSnapshotFormatter.formatNodes(edges.items));+ t.assert.snapshot(HeapSnapshotFormatter.formatNodes(edges.items, {}));});it('formats outgoing edges with pagination', async t => {const edges = await manager.getEdges(examplePath, 25341);t.assert.snapshot(- HeapSnapshotFormatter.formatNodes(edges.items.slice(0, 2)),+ HeapSnapshotFormatter.formatNodes(edges.items.slice(0, 2), {}),);});@@ -522,14 +615,16 @@ describe('HeapSnapshotFormatter', () => {const edges = await manager.getEdges(examplePath, 25341, {minRetainedSize: range?.min,});- t.assert.snapshot(HeapSnapshotFormatter.formatNodes(edges.items));+ t.assert.snapshot(HeapSnapshotFormatter.formatNodes(edges.items, {}));});});describe('formatDominators', () => {it('formats dominator chain for a valid nodeId', async t => {const dominators = await manager.getDominatorsOf(examplePath, 25341);- t.assert.snapshot(HeapSnapshotFormatter.formatDominators(dominators));+ t.assert.snapshot(+ HeapSnapshotFormatter.formatDominators(dominators, {}),+ );});});@@ -560,7 +655,7 @@ describe('HeapSnapshotFormatter', () => {it('formats duplicate strings with default options', async t => {const duplicateStrings = await manager.getDuplicateStrings(examplePath);t.assert.snapshot(- HeapSnapshotFormatter.formatDuplicateStrings(duplicateStrings),+ HeapSnapshotFormatter.formatDuplicateStrings(duplicateStrings, {}),);});});@@ -569,7 +664,7 @@ describe('HeapSnapshotFormatter', () => {it('formats queried objects with default options', async t => {const objects = await manager.queryObjects(examplePath, {});t.assert.snapshot(- HeapSnapshotFormatter.formatNodes(objects.items.slice(0, 10)),+ HeapSnapshotFormatter.formatNodes(objects.items.slice(0, 10), {}),);});@@ -578,7 +673,7 @@ describe('HeapSnapshotFormatter', () => {className: 'Window',});t.assert.snapshot(- HeapSnapshotFormatter.formatNodes(objects.items.slice(0, 10)),+ HeapSnapshotFormatter.formatNodes(objects.items.slice(0, 10), {}),);});@@ -588,7 +683,7 @@ describe('HeapSnapshotFormatter', () => {minRetainedSize: range?.min,});t.assert.snapshot(- HeapSnapshotFormatter.formatNodes(objects.items.slice(0, 10)),+ HeapSnapshotFormatter.formatNodes(objects.items.slice(0, 10), {}),);});@@ -597,7 +692,7 @@ describe('HeapSnapshotFormatter', () => {sortBy: 'selfSize',});t.assert.snapshot(- HeapSnapshotFormatter.formatNodes(objects.items.slice(0, 5)),+ HeapSnapshotFormatter.formatNodes(objects.items.slice(0, 5), {}),);});});@@ -611,7 +706,9 @@ describe('HeapSnapshotFormatter', () => {scriptsWithoutScopes: analysis.scriptsWithoutScopes,};- t.assert.snapshot(HeapSnapshotFormatter.formatContextAnalysis(report));+ t.assert.snapshot(+ HeapSnapshotFormatter.formatContextAnalysis(report, {}),+ );});it('reports when there are no contexts with dead fields', () => {@@ -620,7 +717,7 @@ describe('HeapSnapshotFormatter', () => {scriptsWithoutScopes: [],};- const result = HeapSnapshotFormatter.formatContextAnalysis(report);+ const result = HeapSnapshotFormatter.formatContextAnalysis(report, {});assert.strictEqual(result,diff --git a/tests/tools/memory.test.ts b/tests/tools/memory.test.tsindex 172c8463..c1ad3e0b 100644--- a/tests/tools/memory.test.ts+++ b/tests/tools/memory.test.ts@@ -140,6 +140,7 @@ describe('memory', () => {staticData,nativeContextSizes,retainedByContextSummary,+ {maxNameLength: undefined},);});});@@ -224,6 +225,7 @@ describe('memory', () => {sinon.assert.calledOnceWithExactly(response.setHeapSnapshotNodes, nodes, {pageIdx: undefined,pageSize: undefined,+ maxNameLength: undefined,});});@@ -257,6 +259,7 @@ describe('memory', () => {sinon.assert.calledOnceWithExactly(response.setHeapSnapshotNodes, nodes, {pageIdx: 2,pageSize: 20,+ maxNameLength: undefined,});});});@@ -281,7 +284,7 @@ describe('memory', () => {sinon.assert.calledOnceWithExactly(response.setHeapSnapshotNodes,retainers,- {pageIdx: undefined, pageSize: undefined},+ {pageIdx: undefined, pageSize: undefined, maxNameLength: undefined},);});@@ -311,7 +314,7 @@ describe('memory', () => {sinon.assert.calledOnceWithExactly(response.setHeapSnapshotNodes,retainers,- {pageIdx: 1, pageSize: 5},+ {pageIdx: 1, pageSize: 5, maxNameLength: undefined},);});});@@ -336,6 +339,7 @@ describe('memory', () => {sinon.assert.calledOnceWithExactly(response.setHeapSnapshotObjectDetails,objectInfo,+ {maxNameLength: undefined},);});});@@ -352,6 +356,7 @@ describe('memory', () => {filePath: 'test.heapsnapshot',retainedSize: parseByteSizeRange('10KB'),scopeInfoNodeId: 303,+ maxNameLength: 500,pageIdx: 1,pageSize: 5,},@@ -370,6 +375,7 @@ describe('memory', () => {{retainedSize: {min: 10000, max: undefined},scopeInfoNodeId: 303,+ maxNameLength: 500,pageIdx: 1,pageSize: 5,},@@ -439,6 +445,7 @@ describe('memory', () => {sinon.assert.calledOnceWithExactly(response.setHeapSnapshotRetainingPaths,retainingPaths,+ {maxNameLength: undefined},);});@@ -472,6 +479,7 @@ describe('memory', () => {sinon.assert.calledOnceWithExactly(response.setHeapSnapshotRetainingPaths,retainingPaths,+ {maxNameLength: undefined},);});});@@ -501,6 +509,7 @@ describe('memory', () => {sinon.assert.calledOnceWithExactly(response.setHeapSnapshotNodes, edges, {pageIdx: undefined,pageSize: undefined,+ maxNameLength: undefined,});});@@ -538,6 +547,7 @@ describe('memory', () => {sinon.assert.calledOnceWithExactly(response.setHeapSnapshotNodes, edges, {pageIdx: 0,pageSize: 2,+ maxNameLength: undefined,});});});@@ -562,6 +572,7 @@ describe('memory', () => {sinon.assert.calledOnceWithExactly(response.setHeapSnapshotDominators,dominators,+ {maxNameLength: undefined},);});});@@ -643,7 +654,7 @@ describe('memory', () => {sinon.assert.calledOnceWithExactly(response.setHeapSnapshotDuplicateStrings,duplicateStrings,- {pageIdx: undefined, pageSize: undefined},+ {pageIdx: undefined, pageSize: undefined, maxNameLength: undefined},);});@@ -658,6 +669,7 @@ describe('memory', () => {filePath: 'test.heapsnapshot',pageIdx: 2,pageSize: 10,+ maxNameLength: 1000,},},response,@@ -671,7 +683,7 @@ describe('memory', () => {sinon.assert.calledOnceWithExactly(response.setHeapSnapshotDuplicateStrings,duplicateStrings,- {pageIdx: 2, pageSize: 10},+ {pageIdx: 2, pageSize: 10, maxNameLength: 1000},);});});@@ -706,6 +718,7 @@ describe('memory', () => {sinon.assert.calledOnceWithExactly(response.setHeapSnapshotNodes, range, {pageIdx: undefined,pageSize: undefined,+ maxNameLength: undefined,});});@@ -727,6 +740,7 @@ describe('memory', () => {sortBy: 'selfSize',pageIdx: 1,pageSize: 10,+ maxNameLength: 500,},},response,@@ -751,6 +765,7 @@ describe('memory', () => {sinon.assert.calledOnceWithExactly(response.setHeapSnapshotNodes, range, {pageIdx: 1,pageSize: 10,+ maxNameLength: 500,});});});