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
The VM Service Protocol provides the setExceptionPauseMode API. This API is used by debugging tools like the VSCode Dart Plugin or the IntelliJ Dart plugin when debugging, where the following RPC is sent over from the plugin:
This has the same effect as the set break-on-exception Unhandled command in the debugger, and the --pause-isolates-on-unhandled-exceptions flag to dart.
Problem
With the following code, exceptions that are caught will surface in the debugger. Consider this:
import'package:test/test.dart';
voidmain() {
test('foo', () async {
try {
// Inlining [throwFooException] here also makes the problem go away.awaitthrowFooException();
} onFooException {
print('caught fooexception');
}
});
}
classFooExceptionimplementsException {}
Future<void> throwFooException() async {
// Commenting this out makes the problem go away.// Wait for the next event.awaitFuture(() {});
throwFooException();
}
Running it through the package:test executable, or with dart directly will cause a breakpoint to be added where that exception is thrown, with an awkward backtrace coming from StackZoneSpecification.
With the Test Executable:
pub run test --pause-after-load
Go to the observatory debugger, and enter set break-on-exception Unhandled followed by continue
Observe that a breakpoint has been added where we throw FooException()
Running it with pub run test --pause-after-load --no-chain-stack-traces and repeating the process does not cause the same issue though. The issue is with Chain.capture used to wrap user defined tests here in package:test_api.
With dart
dart run --pause-isolates-on-start --pause-isolates-on-unhandled-exceptions --enable-vm-service bin/dart_debugger_uncaught_exception_repro.dart
Go to the observatory debugger, and enter continue
Observe that a breakpoint has been added where we throw FooException()
Context
This particular pattern is used by, but is not limited to the package:integration_test binding under the hood. A MissingPluginException may be thrown and caught, but it will surface during IDE debugging which is confusing to users.
import'package:stack_trace/stack_trace.dart';
classFooExceptionimplementsException {}
Future<void> throwFooException() async {
// Commenting it out makes the problem go away.// Wait for the next event.awaitFuture(() {});
throwFooException();
}
voidmain() {
Chain.capture(() async {
try {
// Inlining [throwFooException] here also makes the problem go away.awaitthrowFooException();
} onFooException {
print('caught fooexception');
}
});
}
Where the same command of dart run --pause-isolates-on-start --pause-isolates-on-unhandled-exceptions --enable-vm-service bin/dart_debugger_uncaught_exception_repro.dart is able to reproduce it.
What seems to help is when this particular line is commented out. I couldn't quite follow what is going on with the recursion though, so I'm not sure what is the exact cause of this.
Versions
Dart SDK version: 2.13.0-38.0.dev (dev) (Mon Feb 15 10:21:50 2021 -0800) on "macos_x64"
stack_trace: 1.10.0
The text was updated successfully, but these errors were encountered:
The VM Service Protocol provides the
setExceptionPauseMode
API. This API is used by debugging tools like the VSCode Dart Plugin or the IntelliJ Dart plugin when debugging, where the following RPC is sent over from the plugin:When this happens, uncaught exceptions at runtime will surface as breakpoints:
This has the same effect as the
set break-on-exception Unhandled
command in the debugger, and the--pause-isolates-on-unhandled-exceptions
flag todart
.Problem
With the following code, exceptions that are caught will surface in the debugger. Consider this:
Running it through the
package:test
executable, or withdart
directly will cause a breakpoint to be added where that exception is thrown, with an awkward backtrace coming fromStackZoneSpecification
.With the Test Executable:
pub run test --pause-after-load
set break-on-exception Unhandled
followed bycontinue
throw FooException()
Running it with
pub run test --pause-after-load --no-chain-stack-traces
and repeating the process does not cause the same issue though. The issue is withChain.capture
used to wrap user defined tests here inpackage:test_api
.With
dart
dart run --pause-isolates-on-start --pause-isolates-on-unhandled-exceptions --enable-vm-service bin/dart_debugger_uncaught_exception_repro.dart
continue
throw FooException()
Context
This particular pattern is used by, but is not limited to the
package:integration_test
binding under the hood. AMissingPluginException
may be thrown and caught, but it will surface during IDE debugging which is confusing to users.(cc @DanTup)
Smaller Repro
Where the same command of
dart run --pause-isolates-on-start --pause-isolates-on-unhandled-exceptions --enable-vm-service bin/dart_debugger_uncaught_exception_repro.dart
is able to reproduce it.What seems to help is when this particular line is commented out. I couldn't quite follow what is going on with the recursion though, so I'm not sure what is the exact cause of this.
Versions
The text was updated successfully, but these errors were encountered: