Skip to content

Devtool extension authoring: EvalOnDartLibrary, how to recursively inspect an Object without causing Sentinel <expired> due to race conditions? #9634

@rrousselGit

Description

@rrousselGit

Hello!

I think I'm missing something with regards to EvalOnDartLibrary. I fail to see how it is possible to fully map out an object without ever risking an <expired> Sentinel or not loosing the ability to inspect private members.

I am aware that one trick is to do (pseudo code):

final id = eval('globalMap.register(<expression to evaluate>)')

try {
  final content = eval('globalMap.get("$id").<field I want to read>');
} finally {
  eval('globalMap.unregister("$id")');
}

This prevents the <expired>. But afaik, prevents reading private members on the inspected object, due to globalMap and the private members being defined in different libraries.
(also, this will forcibly trigger late fields ; which can be undesired)

If we instead do:

final value= eval('<expression to evaluate>')
final content = eval('that.<field I want to read>', scope: {'that': value.id});

Then we risk that value will expire before content is resolved.

Is there something I'm missing here? Or do we need a new feature to solve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2important to work on, but not at the top of the work list.devtools extensionsIssues related to DevTools extensions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions