Skip to content

Flutter runs with DDC library bundle format sometimes leads to 'Library not defined' errors in the DDC module loader #162567

@srujzs

Description

@srujzs

Steps to reproduce

  1. Use a Windows machine.
  2. Create a Flutter app e.g. flutter create test.
  3. Run it with flutter run -d chrome --extra-front-end-options=--dartdevc-canary,--dartdevc-module-format=ddc.

Expected results

The app should run normally.

Actual results

Logs like the following:

Starting application from main method in: org-dartlang-app:/web_entrypoint.dart.
TypeError: dartDevEmbedder.debugger.getSourceMap is not a function
    at http://localhost:62924/main.dart.js:206:43
    at Function.$1 (http://localhost:62924/stack_trace_mapper.js:5664:46)
    at cH.ah (http://localhost:62924/stack_trace_mapper.js:5315:22)
    at cH.bV (http://localhost:62924/stack_trace_mapper.js:5326:23)
    at eL.$1 (http://localhost:62924/stack_trace_mapper.js:5289:10)
    at q.G (http://localhost:62924/stack_trace_mapper.js:3131:22)
    at I.m (http://localhost:62924/stack_trace_mapper.js:3110:17)
    at bF.m (http://localhost:62924/stack_trace_mapper.js:3229:26)
    at Object.dR (http://localhost:62924/stack_trace_mapper.js:1673:16)
    at Object.a4 (http://localhost:62924/stack_trace_mapper.js:1687:17)
    at Object.f2 (http://localhost:62924/stack_trace_mapper.js:2620:17)
    at Object.l8 (http://localhost:62924/stack_trace_mapper.js:2634:10)
    at d0.l9 (http://localhost:62924/stack_trace_mapper.js:2659:10)
    at Object.jo (http://localhost:62924/stack_trace_mapper.js:389:69)
    at ki (http://localhost:62924/stack_trace_mapper.js:2675:10)
    at http://localhost:62924/stack_trace_mapper.js:2669:42
    at dartDevEmbedder.defineLibrary.dart._StackTrace.missing.toString (http://localhost:62924/dart_sdk.js:5253:19)
    at Object._toString [as toString] (http://localhost:62924/dart_sdk.js:4235:20)
    at http://localhost:62924/dart_sdk.js:294251:39
    at _RootZone.runBinary (http://localhost:62924/dart_sdk.js:42368:59)
    at dartDevEmbedder.defineLibrary.async._FutureListener.then.handleError (http://localhost:62924/dart_sdk.js:35391:30)
    at handleError (http://localhost:62924/dart_sdk.js:36081:49)
    at _Future._propagateToListeners (http://localhost:62924/dart_sdk.js:36107:15)
    at [_completeError] (http://localhost:62924/dart_sdk.js:35943:21)
    at dartDevEmbedder.defineLibrary.async._AsyncAwaitCompleter.new.completeError (http://localhost:62924/dart_sdk.js:33118:38)
    at Object._asyncRethrow (http://localhost:62924/dart_sdk.js:42582:15)
    at http://localhost:62924/dart_sdk.js:202693:49
    at http://localhost:62924/dart_sdk.js:42610:13
    at http://localhost:62924/dart_sdk.js:42620:7
    at http://localhost:62924/dart_sdk.js:42590:7
    at _RootZone.runBinary (http://localhost:62924/dart_sdk.js:42368:59)
    at dartDevEmbedder.defineLibrary.async._FutureListener.thenAwait.handleError (http://localhost:62924/dart_sdk.js:35391:30)
    at handleError (http://localhost:62924/dart_sdk.js:36081:49)
    at _Future._propagateToListeners (http://localhost:62924/dart_sdk.js:36107:15)
    at [_completeError] (http://localhost:62924/dart_sdk.js:35943:21)
    at dartDevEmbedder.defineLibrary.async._AsyncAwaitCompleter.new.completeError (http://localhost:62924/dart_sdk.js:33118:38)
    at Object._asyncRethrow (http://localhost:62924/dart_sdk.js:42582:15)
    at http://localhost:62924/dart_sdk.js:199376:55
    at http://localhost:62924/dart_sdk.js:42610:13
    at http://localhost:62924/dart_sdk.js:42620:7
    at http://localhost:62924/dart_sdk.js:42587:42
    at _RootZone.runUnary (http://localhost:62924/dart_sdk.js:42364:59)
    at dartDevEmbedder.defineLibrary.async._FutureListener.thenAwait.handleValue (http://localhost:62924/dart_sdk.js:35380:26)
    at handleValueCallback (http://localhost:62924/dart_sdk.js:36065:47)
    at _Future._propagateToListeners (http://localhost:62924/dart_sdk.js:36103:15)
    at [_completeWithValue] (http://localhost:62924/dart_sdk.js:35928:21)
    at dartDevEmbedder.defineLibrary.async._AsyncCallbackEntry.new.callback (http://localhost:62924/dart_sdk.js:35971:33)
    at Object._microtaskLoop (http://localhost:62924/dart_sdk.js:42984:13)
    at Object._startMicrotaskLoop (http://localhost:62924/dart_sdk.js:42991:13)
    at tear (http://localhost:62924/dart_sdk.js:3771:46)
    at http://localhost:62924/dart_sdk.js:36366:9

This is a bit of a red herring. This is awaiting the Dart SDK roll from #162259 to get better stack traces. Specifically, cherry-picking dart-lang/sdk@0037a5c into the ddc_module_loader.js within the Flutter cache should get us a better trace. With that, I see link failures in the DDC module loader like the following:

Starting application from main method in: org-dartlang-app:/web_entrypoint.dart.
RethrownDartError: Library not defined: package:flutter/src/widgets/framework.dart. Failed to initialize.
    Non-error `Library not defined: package:flutter/src/widgets/framework.dart. Failed to initialize.` thrown by JS does not have stack trace.
Caught in Dart at:

dart:sdk_internal 5281:22    missing
dart:sdk_internal 3711:14    stackTrace
dart:sdk_internal 42582:74   _asyncRethrow
dart:sdk_internal 199376:55  <fn>
dart:sdk_internal 42610:13   <fn>
dart:sdk_internal 42620:7    <fn>
dart:sdk_internal 42587:42   <fn>
dart:sdk_internal 42364:59   runUnary
dart:sdk_internal 35380:26   handleValue
dart:sdk_internal 36065:47   handleValueCallback
dart:sdk_internal 36103:15   _propagateToListeners
dart:sdk_internal 35928:21   [_completeWithValue]
dart:sdk_internal 35971:33   callback
dart:sdk_internal 42984:13   _microtaskLoop
dart:sdk_internal 42991:13   _startMicrotaskLoop
dart:sdk_internal 3771:46    tear
dart:sdk_internal 36366:9    <fn>


dart:sdk_internal 3746:12    createErrorWithStack
dart:sdk_internal 175055:18  _throw
dart:sdk_internal 175052:18  throwWithStackTrace
dart:sdk_internal 43141:18   callback
dart:sdk_internal 42984:13   _microtaskLoop
dart:sdk_internal 42991:13   _startMicrotaskLoop
dart:sdk_internal 3771:46    tear
dart:sdk_internal 36366:9    <fn>

Code sample

The default counter app should come across this.

Screenshots or Video

No response

Logs

Flutter Doctor output

Doctor output
[Paste your output here]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions