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

Debug sessions often terminate during a hot restart after upgrading to VS Code 1.66 for projects using Isolates #3916

Closed
max-insight opened this issue Apr 7, 2022 · 11 comments
Labels
important Something important! in debugger Relates to the debug adapter or process of launching a debug session in flutter Relates to running Flutter apps is bug
Milestone

Comments

@max-insight
Copy link

max-insight commented Apr 7, 2022

Describe the bug

  • Hot reload works flawlessly on 1.65.2 but upgrading to 1.66 cause frequent disconnection of debugger after few seconds.
  • also disconnects when doing hot restart

To Reproduce
Steps to reproduce the behavior:

  1. Upgrade to VSCODE version 1.66
  2. start debug session on flutter
  3. hot restart or hot reload
  4. see that it disconnect from debug session

Expected behavior
debug session should not disconnect, should work as previously

Versions (please complete the following information):

  • VS Code version: 1.66
  • Dart extension version: v3.38
  • Dart/Flutter SDK version: 2.16.1 / 2.10.3

here the link to issue raised in vscode repo: microsoft/vscode#146448

@DanTup
Copy link
Member

DanTup commented Apr 7, 2022

I'm not able to reproduce this, but can you confirm:

  • What OS you're on
  • What target device you're using

Could you also capture some logs:

  • Run the app and get to the point where you'll be able to reproduce this
  • Run the Dart: Capture Debugging Logs command
  • Trigger the hot reload/hot restart and wait for the disconnect
  • Click Cancel on the logging notification to stop logging and open the log

Ensure there's nothing sensitive in the log, then save and attach it here, or send to me at logs@dartcode.org.

Thanks!

@DanTup DanTup added the awaiting info Requires more information from the customer to progress label Apr 7, 2022
@max-insight
Copy link
Author

max-insight commented Apr 7, 2022

OS: MacOS Monterey 12.0.1 (Apple M1 Pro)
Target Device -> iPad Prod iOS 15.4 simulator
Here is the log attached (I've removed all the sensitive logs)
Dart-Code-Log-2022-03-05 00-45-22.txt

Ps. Downgrade VSCode to 1.65.2 works fine
I tried to replicate with the counter example, couldn't replicate it either.

@DanTup
Copy link
Member

DanTup commented Apr 7, 2022

Thanks - I can't see an obvious reason for the disconnect, but just before it happens we did send two requests to remove the same breakpoint from the same isolate:

[12:45:29 am] [VmService] [Info] [IT White] ==> {"id":"56564","jsonrpc":"2.0","method":"removeBreakpoint","params":{"isolateId":"isolates/931424507374403","breakpointId":"breakpoints/1"}}
[12:45:29 am] [VmService] [Info] [IT White] ==> {"id":"56565","jsonrpc":"2.0","method":"removeBreakpoint","params":{"isolateId":"isolates/931424507374403","breakpointId":"breakpoints/1"}}

The second request fails, which might have led to the failure. I'm not sure why these two requests were sent though. Are you able to isolate a small repro project that triggers the issue you could share? (For example duplicating your project and removing anything sensitive until you have something you can share, or you find the trigger for the issue)?

Failing that, a complete debugging log file (started before you launched the debug session) may help, I might be able to piece it together from that (it will get quite large though.. and it may include things from your project, like path/class names, and any evaluated expressions in the session).

@solgar
Copy link

solgar commented Apr 8, 2022

I had exact issue as @max-insight and after reading @DanTup comment about releasing twice (or more) times same breakpoint I just removed them all (some where even from non existent files) and it started to work - after 10 hot reloads connection is still working. Then I added one valid breakpoint in valid file, first hot reload worked, however second didn't.

Dart-Code-Log-2022-03-05 12-10-58.txt

[12:11:22 PM] [VmService] [Info] [REDACTED] <== {"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params","data":{"request":{"method":"removeBreakpoint","params":{"isolateId":"isolates/1912386512164203","breakpointId":"breakpoints/2"}},"details":"removeBreakpoint: invalid 'breakpointId' parameter: breakpoints/2"}},"id":"6794"}
[12:11:22 PM] [VmService] [Error] [REDACTED] Invalid params

@jeiea
Copy link

jeiea commented Apr 8, 2022

Add reproducible repository for reference. I can't sure it's reliable.

Steps to reproduce

  1. Environment: M1 Mac Monterey 12.3.1
  2. Prepare flutter 2.10.4 or above (I used flutter master, 2.13.0-0.0.pre.440)
  3. Prepare dart-code and flutter extension current stable or above (I used pre-release, v3.39.20220405)
  4. git clone -b vscode-1.66 https://github.com/jeiea/flutter_example.git
  5. code flutter_example
  6. Press ++P, run Pub: Get Packages.
  7. Set breakpoint on lib/main.dart:71. It is return statement.
  8. Press F5, run on any real device of android and iPad.
  9. Try hot restart after text appears and wait until text reappears. It may require multiple times.

Expected behavior

Debugger connection shouldn't be closed.

Actual behavior

Debugger connection is closed, I'm not sure this is reliably reproducible.

@DanTup
Copy link
Member

DanTup commented Apr 8, 2022

Thanks! I'm not sure what's different, but I was just able to repro this using your project above on iPhone Simulator, and I see the same duplicate calls to remove breakpoints in the log.. I'll see what I can find. Thanks!

@DanTup DanTup added in flutter Relates to running Flutter apps in debugger Relates to the debug adapter or process of launching a debug session and removed awaiting info Requires more information from the customer to progress labels Apr 8, 2022
@DanTup DanTup added this to the v3.40.0 milestone Apr 8, 2022
@DanTup
Copy link
Member

DanTup commented Apr 8, 2022

Perhaps related:

Uncaught Error UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "[object Object]".
    at getErrorWithoutStack (node:internal[/process/promises:270:15]())
    at generateUnhandledRejectionError (node:internal[/process/promises:289:15]())
    at processPromiseRejections (node:internal[/process/promises:245:22]())
    at processTicksAndRejections (node:internal[/process/task_queues:97:32]())

I think previously if there was an unhandled exception in the Node VM, it would just report it, but with a warning that in future it would cause the VM to terminate. I wonder if this bug existed all along, but was silent, and now it's terminating the debug adapter.

Edit: Looks like this change was included in Node 15, and VS Code's release notes say this version went to Node 16, so that seems likely.

@DanTup DanTup changed the title flutter hot reloads or hot restart disconnects from debug session in vscode 1.66 Debug sessions often terminate during a hot restart after upgrading to VS Code 1.66 Apr 8, 2022
@DanTup DanTup modified the milestones: v3.40.0, v3.38.2 Apr 8, 2022
@DanTup DanTup added the important Something important! label Apr 8, 2022
@DanTup
Copy link
Member

DanTup commented Apr 8, 2022

I think the reason I couldn't previously reproduce this is that it relies on having multiple isolates.

I'm pushing a release that has a temporary fix (that is, to restore the previous Node JS behaviour of not terminating on unhandled promises), and have opened #3918 to address the underlying cause (unhandled promise rejections and duplicate attempts to remove breakpoints).

@DanTup DanTup changed the title Debug sessions often terminate during a hot restart after upgrading to VS Code 1.66 Debug sessions often terminate during a hot restart after upgrading to VS Code 1.66 for projects using Isolates Apr 8, 2022
@DanTup DanTup closed this as completed in 10a1bd3 Apr 8, 2022
@DanTup
Copy link
Member

DanTup commented Apr 8, 2022

I've published v3.38.2 (stable) and v3.39.20220408 (pre-release) of the Dart extension to fix this issue (there's no update to the Flutter extension).

Please let me know if you're still seeing issues after updating to one of those versions (and reloading). Thanks!

@furkanvatandas
Copy link

Versions

  • VS Code version: 1.66.1
  • Dart extension version: v3.38.2
  • Dart/Flutter SDK version: 2.16.2 / 2.10.4
  • MacOS Catalina 10.15.7

I can't see debug line in flutter_web with v3.38.2

with iOS simulator everything's fine
Screen Shot 2022-04-09 at 11 55 45

but flutter_web, no any value or data in call stack
Screen Shot 2022-04-09 at 11 41 48

@DanTup
Copy link
Member

DanTup commented Apr 9, 2022

@furkanvatandas I suspect you're seeing dart-lang/webdev#1557. There was a change in Chrome v100 that has affected dwds (a component used by Flutter to emulate the Dart VM for web). A fix is being worked on dwds/Flutter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
important Something important! in debugger Relates to the debug adapter or process of launching a debug session in flutter Relates to running Flutter apps is bug
Projects
None yet
Development

No branches or pull requests

5 participants