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

Customer-reported issue with NNBD migration tool: Could not load edit details #42636

Closed
timsneath opened this issue Jul 9, 2020 · 10 comments
Closed
Assignees
Labels
area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool). os-windows type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@timsneath
Copy link
Contributor

Could not load edit details

Error: FormatException: Invalid port (at character 18)
http://127.0.0.1:49968structs.dart
                 ^

Please fill in the following:

Name of package being migrated (if public):
https://github.com/timsneath/win32

What I was doing when this issue occurred:
Made one change in structs.dart and then clicked on the right-hand nav to make another change

Is it possible to work around this issue:
Only by reapplying,

Has this issue happened before, and if so, how often:
Dart SDK version: 2.9.0-20.0.dev.flutter-06cb010247
Additional details:

Thanks for filing!

Stacktrace: auto populated by migration preview tool.

FormatException: Invalid port (at character 18)
http://127.0.0.1:49968structs.dart
                 ^

    at Object.b (http://127.0.0.1:49968/C:/src/win32/lib/src/exceptions.dart?authToken=f6xUMqAyErk%3D:260:3)
    at Object.vh (http://127.0.0.1:49968/C:/src/win32/lib/src/exceptions.dart?authToken=f6xUMqAyErk%3D:267:24)
    at Object.hK (http://127.0.0.1:49968/C:/src/win32/lib/src/exceptions.dart?authToken=f6xUMqAyErk%3D:2088:18)
    at Object.Fr (http://127.0.0.1:49968/C:/src/win32/lib/src/exceptions.dart?authToken=f6xUMqAyErk%3D:3362:50)
    at http://127.0.0.1:49968/C:/src/win32/lib/src/exceptions.dart?authToken=f6xUMqAyErk%3D:3201:3
    at Gs.a (http://127.0.0.1:49968/C:/src/win32/lib/src/exceptions.dart?authToken=f6xUMqAyErk%3D:1513:72)
    at Gs.$2 (http://127.0.0.1:49968/C:/src/win32/lib/src/exceptions.dart?authToken=f6xUMqAyErk%3D:4389:23)
    at WM.$1 (http://127.0.0.1:49968/C:/src/win32/lib/src/exceptions.dart?authToken=f6xUMqAyErk%3D:4381:30)
    at Ji.bv (http://127.0.0.1:49968/C:/src/win32/lib/src/exceptions.dart?authToken=f6xUMqAyErk%3D:4655:25)
    at rq.$0 (http://127.0.0.1:49968/C:/src/win32/lib/src/exceptions.dart?authToken=f6xUMqAyErk%3D:4583:11)
@timsneath timsneath added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) analyzer-nnbd-migration os-windows labels Jul 9, 2020
@timsneath
Copy link
Contributor Author

Screenshot in case it helps:
image

@creativecreatorormaybenot
Copy link
Contributor

Can confirm, this happens all the time with every edit for me.

@kevmoo
Copy link
Member

kevmoo commented Jul 9, 2020

@stereotype441
Copy link
Member

Thanks for the bug report! I'm able to reproduce this. Investigating...

@stereotype441 stereotype441 self-assigned this Jul 9, 2020
@DanTup
Copy link
Collaborator

DanTup commented Aug 21, 2020

I don't know if it's the same issue, but on the latest nightly on Windows I get a lot of errorpopups like this:

Could not add/remove hint
or
Could not load dart file ..\extract_chart_data.dart

They seem to be related to having \ in paths, which is then included in a URL, for example in the network tab I see (note the %5C):

http://127.0.0.1:61559/M:/Dev/Sites/extract_chart_data/lib/..%5Cextract_chart_data.dart?inline=true&authToken=axUG58VB3pc%3D

This happens when clicking one of the action buttons for a path that has backslashes in the displayed path:

Untitled

I wasn't able to make this run from source on Windows to try making changes (it seems to fail to resolve package: paths), though I found this function that might be an appropriate place to handle converting the slashes when going from paths to URLs?

/// Returns the URL that will navigate to the given [target].
String _relativePathToTarget(NavigationTarget target, String unitDir) {
if (target == null) {
// TODO(brianwilkerson) This is temporary support until we can get targets
// for all nodes.
return '';
}
return pathContext.relative(pathMapper.map(target.filePath), from: unitDir);
}

@DanTup
Copy link
Collaborator

DanTup commented Aug 21, 2020

That said, this path looks like it may be incorrect even if you fix the slash:

M:/Dev/Sites/extract_chart_data/lib/..%5Cextract_chart_data.dart

Because extract_chart_data/lib/../extract_chart_data.dart would end up as extract_chart_data/extract_chart_data.dart and that's not correct (the file is inside lib).

@DanTup
Copy link
Collaborator

DanTup commented Aug 21, 2020

@srawlins This change seems to fix one of my issues on Windows (though unsure if it's the best place for it):

diff --git a/pkg/nnbd_migration/lib/src/front_end/region_renderer.dart b/pkg/nnbd_migration/lib/src/front_end/region_renderer.dart
index 2d97c61bbe..702965f83b 100644
--- a/pkg/nnbd_migration/lib/src/front_end/region_renderer.dart
+++ b/pkg/nnbd_migration/lib/src/front_end/region_renderer.dart
@@ -89,7 +89,9 @@ class RegionRenderer {
       //  for all nodes.
       return '';
     }
-    return pathContext.relative(pathMapper.map(target.filePath), from: unitDir);
+    return pathContext
+        .relative(pathMapper.map(target.filePath), from: unitDir)
+        .replaceAll(r'\', '/'); // Ensure all forwards slashes even on Windows.
   }

   /// Return the URL that will navigate to the given [target] in the file at the

(I also needed this for the generate scripts to work on Windows):

diff --git a/pkg/nnbd_migration/tool/codegen/generate_resources.dart b/pkg/nnbd_migration/tool/codegen/generate_resources.dart
index 18695ef2bc..e1a9c86e6a 100644
--- a/pkg/nnbd_migration/tool/codegen/generate_resources.dart
+++ b/pkg/nnbd_migration/tool/codegen/generate_resources.dart
@@ -90,7 +90,8 @@ String base64Encode(List<int> bytes) {

 void compileWebFrontEnd({bool devMode = false}) async {
   var sdkBinDir = path.dirname(Platform.resolvedExecutable);
-  var dart2jsPath = path.join(sdkBinDir, 'dart2js');
+  var dart2jsBinary = Platform.isWindows ? 'dart2js.bat' : 'dart2js';
+  var dart2jsPath = path.join(sdkBinDir, dart2jsBinary);

   // dart2js -m -o output source
   var process = await Process.start(dart2jsPath, [

However the other issue remains (and may be what the earlier comments here were hitting). If I click the button marked 2 here, it normally works.

Untitled

However if I first click the link marked 1 (which opens that file on the left), and then click the button marked 2, then I get an error:

Could not add/remove hint

FileSystemException(path=M:\Dev\Sites\extract_chart_data\lib\data_table.dart; message=Cannot open file)

The path here is missing the "lib". It seems like opening another file may be affecting how the relative path is resolved for the actions in the right panel?

dart-bot pushed a commit that referenced this issue Aug 24, 2020
Bug: #42636 (comment)
Change-Id: I426bf87cfc29f19fdabbc5ce7692dd98e25ba33c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159760
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
dart-bot pushed a commit that referenced this issue Aug 24, 2020
Bug: #42636
Change-Id: I2bda4f91eb6da738b2b2a9c0f0a17d1a71b027cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159780
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
@srawlins
Copy link
Member

@DanTup I've landed a fix for the original issue, which is not specific to Windows. The issue you are seeing may be specific to Windows.

I suspect they are different issues, but if you are able to build Dart at HEAD, could you try with my recent fixes (e7c79ae) and if you still see your issue, open a new issue? Thanks!

@DanTup
Copy link
Collaborator

DanTup commented Aug 25, 2020

@srawlins I can't build, but a nightly build was made an hour ago so I tested with that. I've filed #43178 with a repository and exact steps to reproduce.

@srawlins
Copy link
Member

I'll close this one then.

@stereotype441 stereotype441 added area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool). and removed analyzer-nnbd-migration area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool). os-windows type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

6 participants