Query_heapsnapshot_objects className finds nothing for class names that the other heap tools print, because it matches node names

Open
#2,979 1 comment 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@dinfuehr is already working on this.

Since Oct 13, 2026.

  • #3096 by @lorenzozanee — closed without merging

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript
Domain
devtools

Research direction

Read the query_heapsnapshot_objects description and className parameter in docs/tool-reference.md, then inspect the worker's queryObjects in third_party/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts. Reproduce with the detached DOM fixture and heap snapshot steps in the issue. Done means class names from heap details select the corresponding objects, while the LeakyThing control still works.

Written by the indexing model from the issue text.

Description

confirmed p3
Description of the bug

query_heapsnapshot_objects documents className as matching the "object class name", but it matches each node's name instead. For JavaScript objects the two are the same, so LeakyThing works. For DOM and other native nodes they differ: get_heapsnapshot_details reports the class Detached <div> with 50 objects, yet className: "Detached <div>" (or ^Detached <div>$) returns 0 objects, because those nodes are named Detached <div class="detached-node">. Class names from the details output that contain regular-expression syntax, such as (array), also select unrelated nodes (Array, system / ArrayList, system / DescriptorArray). An agent that copies a class name from one heap tool into this query gets wrong or empty results without any error.

Actual behavior

Both builds (two snapshots per build: the fixture above and a larger leak fixture):

get_heapsnapshot_details (detached filter):
  id,name,count,selfSize,retainedSize
  1,Detached <div>,50,5.2 kB,10.8 kB
query className "Detached <div>"    -> Showing 1-0 of 0   (main: Showing 0-0 of 0)
query className "^Detached <div>$"  -> Showing 1-0 of 0   (main: Showing 0-0 of 0)
query className "Detached <div"     -> 36383,Detached <div class="detached-node">,native,6,0.1 kB,0.2 kB ... Showing 1-2 of 50
query className "(array)"           -> 37509,Array,object,5,...; 46611,system / DescriptorArray,object shape,7,...  Showing 1-3 of 2292

With the larger fixture, className: "Detached" also returned a script source string whose text contains "detached" (the match is case-insensitive and against any node name, including string contents).

Reproduction
  1. Serve this page locally as detached.html:
<!doctype html><title>Detached fixture</title>
<script>
window.kept = [];
for (let i = 0; i < 50; i++) { const d = document.createElement('div'); d.className = 'detached-node'; window.kept.push(d); }
</script>
  1. Send these tool calls:
{"name":"new_page","arguments":{"url":"http://127.0.0.1:<port>/detached.html"}}
{"name":"take_heapsnapshot","arguments":{"pageId":2,"filePath":"<workspace>/snaps/detached.heapsnapshot"}}
{"name":"get_heapsnapshot_details","arguments":{"filePath":"<workspace>/snaps/detached.heapsnapshot","filterName":"objectsRetainedByDetachedDomNodes","pageSize":5}}
{"name":"query_heapsnapshot_objects","arguments":{"filePath":"<workspace>/snaps/detached.heapsnapshot","className":"Detached <div>","pageSize":3}}
{"name":"query_heapsnapshot_objects","arguments":{"filePath":"<workspace>/snaps/detached.heapsnapshot","className":"^Detached <div>$","pageSize":3}}
{"name":"query_heapsnapshot_objects","arguments":{"filePath":"<workspace>/snaps/detached.heapsnapshot","className":"(array)","pageSize":3}}
{"name":"query_heapsnapshot_objects","arguments":{"filePath":"<workspace>/snaps/detached.heapsnapshot","className":"Detached <div","pageSize":2}}
Expectation

The className parameter is "Optional regex or text matching object class name", and the tool description lists it among the filters for "objects matching specific filters (className, ...)". The heap tools present class names in get_heapsnapshot_details and compare_heapsnapshots; a class name printed there, such as Detached <div> or (array), should select the objects of that class (50 detached div elements here), as the same name does for JavaScript classes such as LeakyThing.

MCP configuration

--headless --isolated --no-usage-statistics --no-performance-crux unless the reproduction states otherwise (update checks disabled with CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1).

Chrome DevTools MCP version

1.10.1 (npm) and main 5ddb0a3110c5059f8e5513e566196cce2a35c6d1 (local build)

Chrome version

154.0.8037.98 (stable)

Node version

v22.23.2

Operating system

macOS 27.0

Environment details
  • chrome-devtools-mcp 1.10.1 from npm (the release build) and upstream main at commit 5ddb0a3110c5059f8e5513e566196cce2a35c6d1 built from source (the main build).
  • Google Chrome 154.0.8037.98 (stable), Node.js v22.23.2, macOS 27.
  • Server started with --isolated --headless --no-usage-statistics --no-performance-crux --memoryDebugging and CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1, driven by a minimal stdio MCP client whose workspace root contains <workspace>/snaps/.
Evidence
  • Expected source: query_heapsnapshot_objects description and className parameter in docs/tool-reference.md, both builds; class names as printed by get_heapsnapshot_details on the same snapshot.
  • Failure source: my runs of the steps above on both builds; static breadcrumb: the worker's queryObjects (third_party/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts on the main build) compiles new RegExp(queryOptions.className, 'i') and tests it against the node name.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete
Fix check

Run the steps above. Failing: className: "Detached <div>" returns 0 objects while get_heapsnapshot_details reports 50 Detached <div> objects. Passing: the same query returns those 50 detached div nodes, and className: "(array)" returns the objects that get_heapsnapshot_details counts under (array) rather than Array objects. Control: className: "LeakyThing" (or ^LeakyThing$) on a page with that JavaScript class still returns the same instances as get_heapsnapshot_class_nodes for that class.

Additional context

The full open and closed issue and pull request corpus was screened as of 2026-10-06; no issue covers this. Merged pull request #2553 added the tool. If the maintainers prefer node-name matching, an alternative resolution is a className description that says it matches node names and explains how class names containing regular-expression syntax are treated. An invalid regular expression in className (for example () fails with an internal TypeError; that is a separate problem with its own fix and is not part of this report.

Dominant language
TypeScript
Stars
59.8k
Forks
4.8k
Avg merge
2d 10h
Merged PRs (30d)
162

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ChromeDevTools/chrome-devtools-mcp

All issues in ChromeDevTools/chrome-devtools-mcp

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.