Repository navigation
"flutter attach" fails to connect when using --debug-url #110260
Copy link
Copy link
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectfound in release: 3.0Found to occur in 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1Found to occur in 3.1found in release: 3.3Found to occur in 3.3Found to occur in 3.3has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.Issues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool teamTriaged by Flutter Tool team
Description
If I run a Flutter app with flutter run:
danny@Dannys-MacBook-Pro src % flutter run
// ...
An Observatory debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:55772/yRmpm6wAk9w=/
The Flutter DevTools debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:55772/yRmpm6wAk9w=/
And then try to connect to it using flutter attach with --debug-url, it fails:
danny@Dannys-MacBook-Pro src % flutter attach -d emulator-5554 --debug-url http://127.0.0.1:55772/yRmpm6wAk9w=/
Error connecting to the service protocol: failed to connect to http://127.0.0.1:55918/yRmpm6wAk9w=/
(note the port number in the error is different to the one I provided)
Connecting using the device (-d) seems to work fine.
Passing --debug-url is a workflow supported in VS Code to allow users to attach to Flutter apps that might have been launched externally from VS Code, but currently this fails for the reasons above.
I believe this used to work at some point in the past, because #70847 looks like a fix for a very similar issue, however even if I pass --no-dds to both flutter run and flutter attach here, I see the same failure.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectfound in release: 3.0Found to occur in 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1Found to occur in 3.1found in release: 3.3Found to occur in 3.3Found to occur in 3.3has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.Issues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool teamTriaged by Flutter Tool team
Activity
exaby73 commentedon Aug 25, 2022
Hello @DanTup. Thank you for filling this issue. I can reproduce this issue with the default counter app.
Reproducible on:
Stable (3.0.5)Beta (3.3.0-0.5.pre)Master (3.1.0-0.0.pre.2481)Commands run
Doctor Output
flutter doctor -v(Stable)flutter doctor -v(Master)DanTup commentedon Aug 25, 2022
Reading the code here:
flutter/packages/flutter_tools/lib/src/commands/attach.dart
Lines 307 to 316 in 91fdbfa
Which calls here:
flutter/packages/flutter_tools/lib/src/mdns_discovery.dart
Line 245 in 91fdbfa
It looks like
--debug-urlmight expect a device port, and not the host port. So I think it's setting up a new forwarded port to the supplied port on the device (where nothing is listening). It's possible that what I'm trying to do here is not supported (usually you'd useflutter attachwith an app not launched withflutter run). If that's the case, the fix may be just to improve the description on--debug-urlto make this clearer:flutter/packages/flutter_tools/lib/src/commands/attach.dart
Lines 82 to 84 in 91fdbfa