Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webdev auto restart doesn't work properly #2586

Closed
svarl opened this issue Dec 31, 2019 · 1 comment · Fixed by #2587
Closed

Webdev auto restart doesn't work properly #2586

svarl opened this issue Dec 31, 2019 · 1 comment · Fixed by #2587
Assignees

Comments

@svarl
Copy link

svarl commented Dec 31, 2019

Environment:

Dart VM version: 2.7.0
webdev 2.5.4

How to start:

$ webdev serve --auto restart

I got an exception in browser console when i'm trying to do some changes in web/app/app_component.dart or any other files. That reporduce in the project https://github.com/svarl/quickstart.

VM442:1 Uncaught TypeError: window.$dartRunMain is not a function
    at <anonymous>:1:8
    at Object.runMain (client.js:7952)
    at client.js:23849
    at _wrapJsFunctionForAsync_closure.$protected (client.js:3003)
    at _wrapJsFunctionForAsync_closure.call$2 (client.js:10800)
    at Object._asyncStartSync (client.js:2968)
    at main__closure1.$call$body$main__closure (client.js:23861)
    at main__closure1.call$1 (client.js:23792)
    at StaticClosure._rootRunUnary [as call$2$5] (client.js:3303)
    at _CustomZone.runUnary$2$2 (client.js:12130)
    at _CustomZone.runUnaryGuarded$1$2 (client.js:12058)
    at _ControllerSubscription._sendData$1 (client.js:11601)
    at _DelayedData.perform$1 (client.js:11754)
    at _PendingEvents_schedule_closure.call$0 (client.js:11807)
    at Object._microtaskLoop (client.js:3168)
    at StaticClosure._startMicrotaskLoop (client.js:3174)
    at _AsyncRun__initializeScheduleImmediate_internalCallback.call$1 (client.js:10675)
    at invokeClosure (client.js:1188)
    at MutationObserver.<anonymous> (client.js:1207)

I think the reason why this is happening is *.bootstrap.js file contains invalid appModuleUri:

    if (childName === "app/app_component.css.shim.dart") { // should be main.dart
      // Clear static caches.
      dart_sdk.dart.hotRestart();
      window.$dartRunMain = child.main;
      return true;
    }
@jakemac53
Copy link
Contributor

Confirmed this is due to app/app_component.css.shim.dart as you suggested (it should be main.dart). Likely we considered app/app_component.css.shim.dart as the primary input for the module.

One workaround is to move all but your main.dart file under your lib directory while we work on a fix.

@jakemac53 jakemac53 self-assigned this Jan 2, 2020
jakemac53 added a commit that referenced this issue Jan 2, 2020
When the entrypoint isn't the primary asset of the module we would handle the hot restart at the wrong place (the primary asset), which would either run the wrong app (if it had a main and was available) or give a runtime failure.

Fixes #2586
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 a pull request may close this issue.

2 participants