Skip to content

Cache source maps across DevTools error reports - #10084

Open
AIlhomov wants to merge 1 commit into
flutter:masterfrom
AIlhomov:fix/cache-source-maps
Open

AIlhomov wants to merge 1 commit into
flutter:masterfrom
AIlhomov:fix/cache-source-maps

Conversation

@AIlhomov

Copy link
Copy Markdown
Contributor

Addresses the source-map cache TODO linked to #9910. Other findings in that issue are outside this change.

DevTools fetches a source map at startup, but the result is discarded and the cache fields are never assigned. Reporting another error therefore fetches and parses the map again.

Share one source-map load between startup and error reporting, including concurrent reports. Keep the successful result, and allow a later attempt when loading or parsing fails. The existing JavaScript/WebAssembly map selection and original-stack fallback are preserved.

Testing

  • Browser regression on unchanged production code: failed with 7 fetch attempts where 4 were expected, in both JavaScript and WebAssembly.
  • With the fix: the same regression passed in both modes. It covers missing maps, malformed maps, transport failure, concurrent reports, later reports, startup reuse, and mapped stack output. The four expected attempts are three intentional failures followed by one successful load.
  • A VM test verifies that native error reporting keeps its original stack without fetching a map.
  • Related framework tests: 81 passed.
  • dt presubmit passed, including repository analysis and formatting checks.

Browser tests use a controlled MockClient in Chromium; these request counts are not a network-throughput or timing benchmark. The browser-only test must be run explicitly with flutter test --platform chrome and --wasm for the WebAssembly variant. These automated runs are not an all-platform CI result.

Tested with the repository-pinned Flutter SDK at de37392db4 (Dart 3.15.0-122.0.dev). No dependency or lockfile changes are included.

Manual check: built the complete DevTools app in Docker and opened the JavaScript build in Edge. With a deliberately malformed local DTD response, the app reported readable Dart stack locations and reused the startup source map without a second request. Separately, the real DevTools server and DTD connected successfully, and Network navigation and Settings worked without console errors in that session. No full-app WebAssembly manual check is claimed.

Pre-launch Checklist

General checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read the Flutter Style Guide recently, and have followed its advice.
  • I signed the CLA.
  • I updated/added relevant documentation (doc comments with ///).

Issues checklist

Tests checklist

  • I added new tests to check the change I am making...
  • OR there is a reason for not adding tests, which I explained in the PR description.

AI-tooling checklist

  • I did not use any AI tooling in creating this PR.
  • OR I did use AI tooling, and...
    • I read the AI contributions guidelines and agree to follow them.
    • I reviewed all AI-generated code before opening this PR.
    • I understand and am able to discuss the code in this PR.
    • I have verifed the accuracy of any AI-generated text included in the PR description.
    • I commit to verifying the accuracy of any AI-generated code or text that I upload in response to review comments.

Feature-change checklist

  • This PR does not change the DevTools UI or behavior and...
    • I added the release-notes-not-required label or left a comment requesting the label be added.
  • OR this PR does change the DevTools UI or behavior and...
    • I added an entry to packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md.
    • I included before/after screenshots and/or a GIF demo of the new UI to my PR description. (Not applicable: no visual UI change.)
    • I ran the DevTools app locally to manually verify my changes.

build.yaml badge

If you need help, consider asking for help on Discord.

@AIlhomov
AIlhomov requested a review from a team as a code owner November 10, 2026 21:07
@AIlhomov
AIlhomov requested review from srawlins and removed request for a team November 10, 2026 21:07

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

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.

Code Review

This pull request optimizes error handling in DevTools by reusing source maps across error reports instead of repeatedly fetching and parsing them. It consolidates the platform-specific cached source mappings into a single cached future (_cachedSourceMapping) and updates _fetchSourceMapping to retry failed loads. New tests are introduced to verify this behavior on both VM and web platforms, and the release notes are updated accordingly. I have no feedback to provide.

@srawlins srawlins left a comment

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.

Thanks much!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants