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

[flutter_tools] missing client.js file from dwds #53644

Closed
zzd258147 opened this issue Mar 31, 2020 · 16 comments · Fixed by #65814
Closed

[flutter_tools] missing client.js file from dwds #53644

zzd258147 opened this issue Mar 31, 2020 · 16 comments · Fixed by #65814
Labels
c: crash Stack traces logged to the console P2 Important issues not at the top of the work list platform-web Web applications specifically tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@zzd258147
Copy link

zzd258147 commented Mar 31, 2020

Steps to Reproduce

  1. Run flutter config --enable-web;
  2. Create a new project with flutter create demo123;
  3. Delete all the contents in the /Users/zzd/flutter/.pub-cache folder;
    (Because they are caches, I think it is OK to delete at any time.)
  4. Go to the project folder cd demo123 and Run flutter pub get;
  5. Run flutter run -d chrome;

Logs

Last login: Wed Apr  1 17:28:40 on ttys000
zzd-mac-mini:~ zzd$ flutter config --enable-web
Setting "enable-web" value to "true".

You may need to restart any open editors for them to read new settings.
zzd-mac-mini:~ zzd$ cd /Users/zzd/Desktop/test 
zzd-mac-mini:test zzd$ flutter create demo123
Creating project demo123...
  demo123/ios/Runner.xcworkspace/contents.xcworkspacedata (created)
  demo123/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (created)
  demo123/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
  (created)
  demo123/ios/Runner/Info.plist (created)
  demo123/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
  (created)
  demo123/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
  (created)
  demo123/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md (created)
  demo123/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
  (created)
  demo123/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
  (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
  (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
  (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
  (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
  (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.pn
  g (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.pn
  g (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
  (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
  (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
  (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
  (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
  (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
  (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
  (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
  (created)
  demo123/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
  (created)
  demo123/ios/Runner/Base.lproj/LaunchScreen.storyboard (created)
  demo123/ios/Runner/Base.lproj/Main.storyboard (created)
  demo123/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  (created)
  demo123/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChec
  ks.plist (created)
  demo123/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSetting
  s.xcsettings (created)
  demo123/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme (created)
  demo123/ios/Flutter/Debug.xcconfig (created)
  demo123/ios/Flutter/Release.xcconfig (created)
  demo123/ios/Flutter/AppFrameworkInfo.plist (created)
  demo123/ios/.gitignore (created)
  demo123/test/widget_test.dart (created)
  demo123/demo123.iml (created)
  demo123/.gitignore (created)
  demo123/web/favicon.png (created)
  demo123/web/index.html (created)
  demo123/web/manifest.json (created)
  demo123/web/icons/Icon-192.png (created)
  demo123/web/icons/Icon-512.png (created)
  demo123/.metadata (created)
  demo123/android/app/src/profile/AndroidManifest.xml (created)
  demo123/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (created)
  demo123/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (created)
  demo123/android/app/src/main/res/drawable/launch_background.xml (created)
  demo123/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (created)
  demo123/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (created)
  demo123/android/app/src/main/res/values/styles.xml (created)
  demo123/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (created)
  demo123/android/app/src/main/AndroidManifest.xml (created)
  demo123/android/app/src/debug/AndroidManifest.xml (created)
  demo123/android/gradle/wrapper/gradle-wrapper.properties (created)
  demo123/android/gradle.properties (created)
  demo123/android/.gitignore (created)
  demo123/android/settings.gradle (created)
  demo123/android/app/build.gradle (created)
  demo123/android/app/src/main/kotlin/com/example/demo123/MainActivity.kt
  (created)
  demo123/android/build.gradle (created)
  demo123/android/demo123_android.iml (created)
  demo123/pubspec.yaml (created)
  demo123/README.md (created)
  demo123/ios/Runner/Runner-Bridging-Header.h (created)
  demo123/ios/Runner/AppDelegate.swift (created)
  demo123/ios/Runner.xcodeproj/project.pbxproj (created)
  demo123/lib/main.dart (created)
  demo123/.idea/runConfigurations/main_dart.xml (created)
  demo123/.idea/libraries/Flutter_for_Android.xml (created)
  demo123/.idea/libraries/Dart_SDK.xml (created)
  demo123/.idea/libraries/KotlinJavaRuntime.xml (created)
  demo123/.idea/modules.xml (created)
  demo123/.idea/workspace.xml (created)
Running "flutter pub get" in demo123...                             3.3s
Wrote 77 files.

All done!
[✓] Flutter: is fully installed. (Channel dev, v1.16.3, on Mac OS X 10.14.6
    18G1012, locale en-CN)
[✗] Android toolchain - develop for Android devices: is not installed.
[✓] Xcode - develop for iOS and macOS: is fully installed. (Xcode 11.3.1)
[✓] Chrome - develop for the web: is fully installed.
[!] Android Studio: is not available. (not installed)
[✓] VS Code: is fully installed. (version 1.43.2)
[✓] Connected device: is fully installed. (2 available)

Run "flutter doctor" for information about installing additional components.

In order to run your application, type:

  $ cd demo123
  $ flutter run

Your application code is in demo123/lib/main.dart.

zzd-mac-mini:test zzd$ cd /Users/zzd/flutter/.pub-cache 
zzd-mac-mini:.pub-cache zzd$ ls
_temp	hosted
zzd-mac-mini:.pub-cache zzd$ rm -rf _temp
zzd-mac-mini:.pub-cache zzd$ rm -rf hosted
zzd-mac-mini:.pub-cache zzd$ ls
zzd-mac-mini:.pub-cache zzd$ cd /Users/zzd/Desktop/test/demo123 
zzd-mac-mini:demo123 zzd$ flutter pub get
Running "flutter pub get" in demo123...                             3.6s
zzd-mac-mini:demo123 zzd$ flutter run -d chrome
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure
you trust this source!
Downloading Web SDK...                                              1.8s
Launching lib/main.dart on Chrome in debug mode...
Syncing files to device Chrome...                                       
18,358ms (!)                                       
ERROR - 2020-04-01 17:34:31.451774
GET /dwds/src/injected/client.js
Error thrown by handler.
FileSystemException: Cannot open file, path = '/Users/zzd/flutter/.pub-cache/hosted/pub.flutter-io.cn/dwds-3.0.0/lib/src/injected/client.js' (OS Error: No such file or directory, errno = 2)
dart:isolate  _RawReceivePortImpl._handleMessage

^Czzd-mac-mini:demo123 zzd$ 

flutter doctor -v

[✓] Flutter (Channel dev, v1.16.3, on Mac OS X 10.14.6 18G1012, locale en-CN)
    • Flutter version 1.16.3 at /Users/zzd/flutter
    • Framework revision be3a4b37b3 (5 days ago), 2020-03-26 18:08:05 -0700
    • Engine revision b2bdeb3f0f
    • Dart version 2.8.0 (build 2.8.0-dev.17.0 1402e8e1a4)

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from:
      https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK
      components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup
      for detailed instructions).
      If the Android SDK has been installed to a custom location, set
      ANDROID_SDK_ROOT to that location.
      You may also want to add it to your PATH environment variable.


[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C505
    • CocoaPods version 1.8.4

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from
      https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup
      for detailed instructions).

[✓] VS Code (version 1.43.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.8.1

 
[✓] Connected device (2 available)            
    • Chrome     • chrome     • web-javascript • Google Chrome 80.0.3987.162
    • Web Server • web-server • web-javascript • Flutter Tools

! Doctor found issues in 2 categories.

Related to #52931

@VladyslavBondarenko VladyslavBondarenko added platform-web Web applications specifically tool Affects the "flutter" command-line tool. See also t: labels. c: crash Stack traces logged to the console labels Mar 31, 2020
@ferhatb ferhatb added the dependency: dart Dart team may need to help us label Mar 31, 2020
@jmagman
Copy link
Member

jmagman commented Mar 31, 2020

Does /Users/zzd/.pub-cache/hosted/ exist? What's in those directories?
That file seems to exist in the package https://github.com/dart-lang/webdev/blob/dwds-v3.0.1/dwds/lib/src/injected/client.js.

@jmagman jmagman added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 31, 2020
@zzd258147
Copy link
Author

Hi jmagman,

Thanks for replay, I have update the issue descriptions and provide full logs.

When the issue occurs, the dwds is not in that folder:

zzd-mac-mini:pub.flutter-io.cn zzd$ cd /Users/zzd/flutter/.pub-cache 
zzd-mac-mini:.pub-cache zzd$ ls
_temp	hosted
zzd-mac-mini:.pub-cache zzd$ cd hosted/
zzd-mac-mini:hosted zzd$ ls
pub.flutter-io.cn
zzd-mac-mini:hosted zzd$ cd pub.flutter-io.cn/
zzd-mac-mini:pub.flutter-io.cn zzd$ ls
archive-2.0.11		boolean_selector-1.0.5	convert-2.1.1		image-2.1.4		path-1.6.4		source_span-1.5.5	string_scanner-1.0.5	typed_data-1.1.6
args-1.5.2		charcode-1.1.2		crypto-2.1.3		matcher-0.12.6		petitparser-2.4.0	stack_trace-1.9.3	term_glyph-1.1.0	vector_math-2.0.8
async-2.4.0		collection-1.14.11	cupertino_icons-0.1.3	meta-1.1.8		quiver-2.0.5		stream_channel-2.0.0	test_api-0.2.15		xml-3.5.0
zzd-mac-mini:pub.flutter-io.cn zzd$ 

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 1, 2020
@jmagman
Copy link
Member

jmagman commented Apr 1, 2020

Can we also get your pubspec.yaml?

@jmagman jmagman added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 1, 2020
@jonahwilliams
Copy link
Member

This is definitely odd. We're already unconditionally running a pub get in the tool for dwds, which should ensure that all of the relevant sources are downloaded:

https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart#L411

(This should probably be updated to only do so when .packages or the files are missing, but that is unrelated).

I wonder if this is the revenge of the pub cache override we've been doing, or something odd with Isolate package resolution

@jonahwilliams jonahwilliams self-assigned this Apr 1, 2020
@jonahwilliams
Copy link
Member

@jmagman I'm going to take a look at this one, since this is a "shouldn't happen" sort of issue in the tool

@jonahwilliams jonahwilliams removed dependency: dart Dart team may need to help us waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Apr 1, 2020
@jonahwilliams jonahwilliams changed the title [flutter_tools] Cannot open file client.js [flutter_tools] missing client.js file from dwds Apr 1, 2020
@jmagman jmagman added this to Awaiting triage in Tools - web review via automation Apr 1, 2020
@yjbanov yjbanov added this to the April 2020 milestone Apr 2, 2020
@yjbanov
Copy link
Contributor

yjbanov commented Apr 2, 2020

@jonahwilliams Optimistically putting this under April, but feel free to move around.

@franco-swarts
Copy link

franco-swarts commented Apr 3, 2020

I had a similar problem. Switching to the beta branch fixed the issue for me.

  • flutter channel beta
  • flutter upgrade

Then try and rebuild and run your web app.

@creativecreatorormaybenot
Copy link
Contributor

This has also been reported on StackOverflow. The original comment could be boiled down to:

ERROR - 2020-04-12 22:45:45.952536
GET /dwds/src/injected/client.js
Error thrown by handler.
FileSystemException: Cannot open file, 
path = '<pub_cache_path>/hosted/pub.dartlang.org/dwds-3.0.2/lib/src/injected/client.js' 
(OS Error: The system cannot find the path specified., errno = 3)

For me it started appearing after I had cleared my cache.


The beta fix worked for me as well, however, I was able to run the same app on master before.

@jonahwilliams jonahwilliams moved this from Awaiting triage to Engineer reviewed in Tools - web review Apr 12, 2020
@sgehrman

This comment was marked as abuse.

@Hixie Hixie modified the milestones: April 2020, Overdue May 5, 2020
@noelli
Copy link

noelli commented May 11, 2020

same issue here.

Debug Output:

ERROR - 2020-05-11 22:15:33.575469
GET /dwds/src/injected/client.js
Error thrown by handler.
FileSystemException: Cannot open file, path = '/Users/tobi/.pub-cache/hosted/pub.dartlang.org/dwds-3.0.2/lib/src/injected/client.js' (OS Error: No such file or directory, errno = 2)
dart:isolate  _RawReceivePortImpl._handleMessage

I tried the following commands but nothing changed:
flutter channel beta
flutter upgrade
flutter create .

Command Output:

% flutter channel beta
Switching to flutter channel 'beta'...
git: From https://github.com/flutter/flutter
git:    c2b7342ca4..a849daf283  dev                   -> origin/dev
git:  * [new branch]            flutter-1.18-candidate.12 -> origin/flutter-1.18-candidate.12
git:  * [new branch]            flutter-1.18-candidate.13 -> origin/flutter-1.18-candidate.13
git:  * [new branch]            flutter-1.19-candidate.0 -> origin/flutter-1.19-candidate.0
git:  * [new branch]            flutter-1.19-candidate.1 -> origin/flutter-1.19-candidate.1
git:    8fbfe1cfbf..5ce84f7733  master                -> origin/master
git:  * [new branch]            revert-56924-hide_tsi -> origin/revert-56924-hide_tsi
git:  * [new tag]               1.18.0-13.0.pre       -> 1.18.0-13.0.pre
git:  * [new tag]               1.19.0-0.0.pre        -> 1.19.0-0.0.pre
git: Already on 'beta'
git: Your branch is up to date with 'origin/beta'.
Successfully switched to flutter channel 'beta'.
To ensure that you're on the latest build from this channel, run 'flutter
upgrade'

% flutter upgrade
Flutter is already up to date on channel beta
Flutter 1.17.0 • channel beta • https://github.com/flutter/flutter.git
Framework • revision e6b34c2b5c (9 days ago) • 2020-05-02 11:39:18 -0700
Engine • revision 540786dd51
Tools • Dart 2.8.1


 % flutter create .
 
Recreating project ....                     
Wrote 3 files.

All done!
[✓] Flutter: is fully installed. (Channel beta, v1.17.0, on Mac OS X 10.15.4 19E287, locale de-DE)
[✓] Android toolchain - develop for Android devices: is fully installed. (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS: is fully installed. (Xcode 11.4.1)
[✓] Chrome - develop for the web: is fully installed.
[✓] Android Studio: is fully installed. (version 3.5)
[✓] VS Code: is fully installed. (version 1.45.0)
[✓] Connected device: is fully installed. (2 available)

@innomon
Copy link

innomon commented May 12, 2020

adding the following in the pubspec.yaml worked for me. I am using beta channel.
dependencies:
dwds: ^3.1.1

@noelli
Copy link

noelli commented May 12, 2020

adding the following in the pubspec.yaml worked for me. I am using beta channel.
dependencies:
dwds: ^3.1.1

Just tried that, did not really help because flutter_tools dependet on dwds: 3.0.2 in my case.

But looking into the pubspec.yaml of flutter_tools i found a work-around which should work with any version of dwds:

flutter update-packages

@jiteshstack
Copy link

adding the following in the pubspec.yaml worked for me. I am using beta channel.

dependencies: dwds: ^3.1.1

then run command:

flutter update-packages

@jasonspick
Copy link

jasonspick commented May 28, 2020

I had the same issue, beta channel 1.18.

All I needed to do was run flutter update-packages

@jonahwilliams jonahwilliams modified the milestones: Overdue, 1.21 - August 2020 Jun 3, 2020
@jonahwilliams jonahwilliams removed their assignment Jun 9, 2020
@jmagman jmagman added the P2 Important issues not at the top of the work list label Aug 18, 2020
@phackwer
Copy link

I had the same issue, beta channel 1.18.

All I needed to do was run flutter update-packages

JESUS!!! It worked for me too! But why?! Can someone explain it? I had 5 different projects, all were running but one.

jonahwilliams added a commit that referenced this issue Sep 17, 2020
…che tool pub dependencies (#65814)

If the tool is downloaded from a precompiled snapshot, or if the backing source files in the pub cache are deleted, the dwds debugging functionality will break as the client.js file cannot be located. Instead use the PackageConfig to verify that package location, downloading if it is missing.

Override the dwds middleware to avoid Isolate.resolvePackageUri

Fixes #53644
Fixes #65475
goderbauer pushed a commit to goderbauer/flutter that referenced this issue Sep 18, 2020
…che tool pub dependencies (flutter#65814)

If the tool is downloaded from a precompiled snapshot, or if the backing source files in the pub cache are deleted, the dwds debugging functionality will break as the client.js file cannot be located. Instead use the PackageConfig to verify that package location, downloading if it is missing.

Override the dwds middleware to avoid Isolate.resolvePackageUri

Fixes flutter#53644
Fixes flutter#65475
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console P2 Important issues not at the top of the work list platform-web Web applications specifically tool Affects the "flutter" command-line tool. See also t: labels.
Projects
Tools - web review
  
Engineer reviewed