Skip to content

Fix late initialization error in DevTools store logic#9816

Merged
kenzieschmoll merged 3 commits into
flutter:masterfrom
kenzieschmoll:fix-server
May 1, 2026
Merged

Fix late initialization error in DevTools store logic#9816
kenzieschmoll merged 3 commits into
flutter:masterfrom
kenzieschmoll:fix-server

Conversation

@kenzieschmoll
Copy link
Copy Markdown
Member

@kenzieschmoll kenzieschmoll commented May 1, 2026

Required for 2.58.0 release.

@kenzieschmoll kenzieschmoll requested a review from bkonyi as a code owner May 1, 2026 16:27
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request reorders the initialization logic in the DevToolsUsage constructor, moving the _removeLegacyKeys call after the properties object is initialized to resolve a late initialization error. While this change fixes the immediate initialization issue, feedback was provided regarding the persistence of the cleanup logic; currently, _removeLegacyKeys only removes keys from memory, meaning they will reappear on subsequent runs unless the removal is properly persisted to disk.

storeName,
documentDirPath: LocalFileSystem.devToolsDir(),
);
_removeLegacyKeys();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

[CONCERN] While moving this call fixes the late initialization error, the _removeLegacyKeys method (and the IOPersistentProperties.remove method it calls) does not currently persist changes to disk. This means legacy keys are only removed from memory and will reappear on the next run. Consider updating _removeLegacyKeys to use properties[key] = null or fixing IOPersistentProperties.remove to ensure the cleanup is permanent.

References
  1. The style guide emphasizes focusing on logic and architectural consistency. The current implementation of the cleanup logic is logically flawed as it lacks persistence. (link)

@kenzieschmoll kenzieschmoll requested a review from a team as a code owner May 1, 2026 16:41
@kenzieschmoll kenzieschmoll requested review from srawlins and removed request for a team May 1, 2026 16:41
@kenzieschmoll kenzieschmoll merged commit 7d9ae43 into flutter:master May 1, 2026
88 of 89 checks passed
@kenzieschmoll kenzieschmoll deleted the fix-server branch May 1, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants