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

Aperta
#2,979 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@dinfuehr ci sta già lavorando.

Dal 13/10/2026.

  • #3096 di @lorenzozanee — chiusa senza merge

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
devtools

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
59.8k
Fork
4.8k
Merge medio
2g 10h
PR unite (30g)
162

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ChromeDevTools/chrome-devtools-mcp

Tutte le issue di ChromeDevTools/chrome-devtools-mcp

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.