Skip to content

Test runs pause on an exception "ExitWithException" if pause-on-uncaught-exceptions is enabled #2949

Closed

Description

@DanTup

When running a simple test file with break-on-uncaught-exceptions on a recent SDK, the debugger pauses at the end on an "ExitWithException" error:

Screenshot 2020-11-10 at 15 35 05

We don't jump to anywhere in the source, so this appears somewhat silent and leads to a confusing experience.

(this is also causing test failures because the debug session doesn't end as expected)

Activity

  1. added
    in debuggingRelates to the debug adapter or process of running debug sessions
    in testingRelates to test execution of Dart/Flutter tests for end users
    on Nov 10, 2020
  2. added this to the v3.17.0 milestone on Nov 10, 2020
  3. DanTup commented on Nov 10, 2020

    @DanTup
    MemberAuthor

    @sigurdm @jonasfj I found this exception in the pub codebase, so I wondered if you might have any ideas about it. I'm running tests through pub and this exception (ExitWithException) seems to be thrown after the test run has completed - but this causes the debugger to pause.

    I may be able to work around it (for example in the test runner, when we see the final event, disable pause-on-exceptions and resume any paused isolates) but I wanted to check if it seems like expected behaviour first - as far as I can tell it's only started occurring recently (while searching for the exception name I found dart-lang/pub#2704 which is recent - and although it doesn't look like it adds any new code throwing this exception - it does seem exit related, so I thought you might be familiar with this area :-))

  4. sigurdm commented on Nov 10, 2020

    @sigurdm

    We changed how pub exits to streamline integration into dart pub ..
    Instead of just exiting with the exit code we throw this to do a non-local exit. I guess this creates a problem due to the way you observe the pub process. (You should really only observe the "test" process that pub starts, not the outer pub process.

    Not sure what is the best way out here. We can stop using Exceptions for non-local control-flow, I think that would just give a bit more boiler-plate. But we can also look into how Dart-Code runs the tests. (It should probably soon use dart test anyways, and after: https://dart-review.googlesource.com/c/sdk/+/171281 dart testno longer relies onpub run`, that would probably make things work again.

  5. sigurdm commented on Nov 10, 2020

    @sigurdm

    I'll be back Thursday to discuss further.

  6. DanTup commented on Nov 10, 2020

    @DanTup
    MemberAuthor

    It should probably soon use dart test anyways

    That was briefly touched on in #2944 (comment). Right now we use dart [pub-snapshot] run test instead of pub run test so we can pass VM flags (like --start-paused).

    If dart test will solve this issue (without reintroducing any of the problems we'd been working around by calling dart [pub-snapshot] then that sounds like the way forward.

    I tested out my workaround and it seems to work. I already had code that sets break-on-exceptions to none, removes all breakpoints and resumes all threads (which we call during IDE-initiated shutdown) and calling that in the done event of the test runner seems to also fix this.

    I'll do some testing with dart test on the latest nightly anyway and ping back here with my findings. Thanks!

  7. changed the title [-]Test runs pause on an exception "ExitWithException" if caught-uncaught-exceptions is enabled[/-] [+]Test runs pause on an exception "ExitWithException" if pause-on-uncaught-exceptions is enabled[/+] on Nov 10, 2020
  8. DanTup commented on Nov 10, 2020

    @DanTup
    MemberAuthor

    I tried using dart test, though I found that with --pause_isolates_on_start=true it would be paused but not print the VM Service URI. If I tried adding --write-service-info=foo.txt it also didn't write the VM Service info there. I don't know whether those are complicated or simple things to address though.

    For now, I'll commit my workaround to resolve this issue. I've opened a new issue at #2950 about migrating to dart test where we can figure out how (or if) it can be done there with less urgency. Thanks!

  9. added a commit that references this issue on Nov 10, 2020
    c7b10e5
  10. DanTup commented on Nov 12, 2020

    @DanTup
    MemberAuthor

    This seems to impact Android Studio too - I've filed flutter/flutter-intellij#5043 in case it needs a workaround there if there's not an easy fix in Pub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in debuggingRelates to the debug adapter or process of running debug sessionsin testingRelates to test execution of Dart/Flutter tests for end usersis bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions