You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Test runs pause on an exception "ExitWithException" if pause-on-uncaught-exceptions is enabled #2949
@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 :-))
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.
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!
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
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!
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.
Activity
DanTup commentedon Nov 10, 2020
@sigurdm @jonasfj I found this exception in the
pubcodebase, so I wondered if you might have any ideas about it. I'm running tests throughpuband 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 :-))
sigurdm commentedon Nov 10, 2020
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 testanyways, and after: https://dart-review.googlesource.com/c/sdk/+/171281dart testno longer relies onpub run`, that would probably make things work again.sigurdm commentedon Nov 10, 2020
I'll be back Thursday to discuss further.
DanTup commentedon Nov 10, 2020
That was briefly touched on in #2944 (comment). Right now we use
dart [pub-snapshot] run testinstead ofpub run testso we can pass VM flags (like--start-paused).If
dart testwill solve this issue (without reintroducing any of the problems we'd been working around by callingdart [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
doneevent of the test runner seems to also fix this.I'll do some testing with
dart teston the latest nightly anyway and ping back here with my findings. Thanks![-]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[/+]DanTup commentedon Nov 10, 2020
I tried using
dart test, though I found that with--pause_isolates_on_start=trueit would be paused but not print the VM Service URI. If I tried adding--write-service-info=foo.txtit 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 testwhere we can figure out how (or if) it can be done there with less urgency. Thanks!Prevent pub exit exeption from pausing the debugger
DanTup commentedon Nov 12, 2020
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.