Skip to content

Too aggressively caching pub root directories #6882

Closed
@elliette

Description

@elliette

This is a follow-up to #6841 (which was fixed by #6857)

This issue explains why our inspector_service tests failed to detect the regression. Once we infer the pub root directory for a project, we cache it across subsequent loads of DevTools, and never try to re-infer it.

Explanation of current behavior:

When DevTools is opened for the first time, or after the cache has been cleared:

  1. No cached directories are added to the widget inspector service (code link)
  2. Fetching directories from the widget inspector service returns nothing (code)
  3. Therefore, DevTools tries to infer the pub root directory (“Directory A”) and adds it to the widget inspector service (code)
  4. Directory A is then cached (code)

On any subsequent loads of DevTools:

  1. The cached Directory A is added to the widget inspector service (code link)
  2. Directory A is fetched from the widget inspector service (code)
  3. Because Directory A was fetched, we do not try to infer the pub root directory (code)

Expected behavior

I believe the caching was added because we want to save any project directories manually added by a user in the Inspector Panel settings dialogue (code). However, I don't think we want to ever cache the inferred pub root directory.

Potential fixes

  1. Always inferring the app's pub root directory but do not change any of our caching logic (but this means any stale inferred pub root directories stick around in the cache)
  2. Always inferring the app's pub root directory and do change our caching logic to only cache pub root directories that users have manually set (but this would mean invalidating all the caches first, and then users would have to re-add any custom pub root directories that they had previously set)

If we go with potential fix #1, we should also consider removing the flutter pub root directory if we detect it in the cache, since the flutter pub root directory was being erroneously inferred (the cause of #6841) and is now cached for any apps that encountered that issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3issues we think are valid but not importantcost: mediumMedium engineering cost to implementscreen: inspector

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions