Skip to content

Unexpected paths in Flutter web error stacks #158109

@DanTup

Description

@DanTup

Steps to reproduce

  1. Create a new counter app
  2. Add debugPrintStack() to the _incrementCounter method
  3. Run on a web device and click the button

Expected results

The printed stack trace should have package: URIs that the IDE can link up so they are clickable.

Actual results

The links are relative paths starting with packages/ that do not exist on disk, so the IDE is unable to link them correctly.

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Original report from dart-lang/webdev#949,


This is similar to #379, though the packages a less weird now - but they're not in the format I would expect. I'm not sure where the problem lies though (webdev, Flutter, or somewhere else).

I've got a simple Flutter app that throws an exception:

https://github.com/Dart-Code/Dart-Code/blob/484ebc5836a73eb8109fcf28f539a9c3c1df5a2a/src/test/test_projects/flutter_hello_world/lib/broken.dart

If I run it with flutter run -d chrome -t lib/broken.dart This is what I get:

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following _Exception was thrown building MyBrokenHomePage(dirty):
Exception: Oops

The relevant error-causing widget was:
  MyBrokenHomePage
  file:///Users/danny/Dev/Dart-Code/src/test/test_projects/flutter_hello_world/lib/broken.dart:34:30

When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 195:49  throw_
packages/hello_world/broken.dart 58:5                                         [_throwAnException]
packages/hello_world/broken.dart 53:5                                         build
packages/flutter/src/widgets/framework.dart 4576:28                           build
packages/flutter/src/widgets/framework.dart 4502:15                           performRebuild
packages/flutter/src/widgets/framework.dart 4218:5                            rebuild
packages/flutter/src/widgets/framework.dart 4481:5                            [_firstBuild]
packages/flutter/src/widgets/framework.dart 4476:5                            mount

Everywhere that has packages/ I would expect to see package:. To the client, "packages/hello_world" is a path that doesn't match anything on disk (there is no packages folder on disk, I think this comes from the URL used to serve them to the browser). This means we don't match them up correctly to make the filenames in the stack trace clickable.

(it's probably not difficult for me to do a replacement on packages/ at the start of a line, but other tools/command line users might also be tripped up by this).

Flutter Doctor output

Doctor output
[!] Flutter (Channel master, 3.27.0-1.0.pre.51, on Microsoft Windows [Version 10.0.22631.4317], locale en-GB)
    • Flutter version 3.27.0-1.0.pre.51 on channel master at D:\Dev\Google\Flutter\Flutter main
    ! Warning: `dart` on your path resolves to D:\Tools\Dart\Stable\bin\dart.exe, which is not inside your current Flutter SDK checkout at
      D:\Dev\Google\Flutter\Flutter main. Consider adding D:\Dev\Google\Flutter\Flutter main\bin to the front of your path.
    • Upstream repository [email protected]:DanTup/flutter.git
    • FLUTTER_GIT_URL = [email protected]:DanTup/flutter.git
    • Framework revision 6829c6a9b9 (3 weeks ago), 2024-10-15 22:36:36 +0800
    • Engine revision 107ea8baa4
    • Dart version 3.6.0 (build 3.6.0-334.2.beta)
    • DevTools version 2.40.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and
      upgrades.

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc3)
    • Android SDK at C:\Users\danny\AppData\Local\Android\sdk
    • Platform android-35, build-tools 35.0.0-rc3
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.5)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.10.35122.118
    • Windows 10 SDK version 10.0.22621.0

[✓] Android Studio (version 2023.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)

[✓] VS Code (version 1.95.1)
    • VS Code at C:\Users\danny\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.101.20241031

[✓] VS Code (version 1.93.0-insider)
    • VS Code at C:\Users\danny\AppData\Local\Programs\Microsoft VS Code Insiders
    • Flutter extension version 3.95.20240801

[✓] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22631.4317]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 130.0.6723.92
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 127.0.2651.86

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listfound in release: 3.24Found to occur in 3.24found in release: 3.27Found to occur in 3.27has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions