Skip to content

Source maps in flutter run -d chrome --release doesn't work for path dependencies (and maybe other situations) #151641

@mkustermann

Description

@mkustermann

If we take the flutter counter app (created via flutter create app) and modify it slightly via

dependencies:
+  helper:
+    path: ../helper

and

+ import 'package:helper/helper.dart';
...
+ int i = 0;
class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;   
                                                                                                                                        
  void _incrementCounter() {                                                                                                            
+    if (++i % 5 == 0) helper(() => throw 'baz');                                                                                                      
    setState(() {

and have the helper method in package:helper call some things which eventually call the given closure to it

// package:helper/helper.dart (aka ../helper/lib/helper.dart)
helper(void Function() fun) {
  print('helper');
  helper1(fun);
}

helper1(void Function() fun) {
  print('helper2');
  helper2(fun);
}

helper2(void Function() fun) {
  print('helper2');
  fun();
}

, then we can break on the exception in chrome.

What we'll observe is that

  • The core library methods have no source maps (e.g. js_helper.dart:throwExpression)
  • The lib/main.dart has valid source maps
  • The package:helper/helper.dart has invalid source maps (for me it shows a html file in chrome)
  • The package:flutter/* code has valid source maps

So either

  • we have to instruct dart2js to emit different source maps for packages (e.g. package:helper in this case) or
  • we have to make the flutter run tool's http server serve the files for the filepaths currently emitted by dart2js

(On dart2wasm this issue doesn't exist because we currently bake in absolute file url which work very well on developer machines, see dart-lang/sdk#56232 for follow up tasks)

/cc @yjbanov @sigmundch @a-siva for finding someone to own this

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: debuggingDebugging, breakpoints, expression evaluationa: releaseChallenges faced when attempting to productionize an appfound in release: 3.22Found to occur in 3.22found in release: 3.24Found to occur in 3.24has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyteam-webOwned by Web platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-webTriaged by Web platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions