Skip to content

Commit da8ed22

Browse files
DanTupCommit Queue
authored andcommitted
[dds/dap] Prevent exceptions writing to stdout.nonBlocking from going unhandled
Because we use `nonBlocking`, the stream closing with unflushed data can result in an unhandled exception. Since we're never interested in errors writing to the stream (there's nothing we can do if the output stream is closed, and it happens at the end of every session), we just discard the error. Fixes #61193 Fixes #55685 Fixes #55313 Change-Id: I6e0a332708cd6e8eb3ae8bd60d45c9e117d897a6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452440 Reviewed-by: Ben Konyi <[email protected]> Reviewed-by: Helin Shiah <[email protected]> Commit-Queue: Helin Shiah <[email protected]>
1 parent 278ea48 commit da8ed22

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

pkg/dartdev/lib/src/commands/debug_adapter.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ class DebugAdapterCommand extends DartdevCommand {
6767
final args = argResults!;
6868
final ipv6 = args.flag(argIpv6);
6969

70+
// Because we use stdout.nonBlocking, exceptions may go unhandled if the
71+
// stream closes while data is being flushed ("The pipe is being closed").
72+
// To prevent this, install an error handler that ignores any errors writing
73+
// to the stream.
74+
stdout.nonBlocking.done.catchError((e) {});
75+
7076
final server = DapServer(
7177
stdin,
7278
stdout.nonBlocking,

pkg/dds/test/dap/integration/debug_attach_test.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ main() {
1313
group('debug mode', () {
1414
late DapTestSession dap;
1515
setUp(() async {
16-
dap = await DapTestSession.setUp(
17-
/// This boolean is temporarily set to `true` to aid debugging
18-
/// https://github.com/dart-lang/sdk/issues/55313 and will be reverted
19-
/// soon.
20-
forceVerboseLogging: true,
21-
);
16+
dap = await DapTestSession.setUp();
2217
});
2318
tearDown(() => dap.tearDown());
2419

pkg/dds/test/dap/integration/debug_exceptions_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ main() {
1212
group('debug mode', () {
1313
late DapTestSession dap;
1414
setUp(() async {
15-
// Temporarily enable verbose logging to help track down
16-
// https://github.com/dart-lang/sdk/issues/55685
17-
dap = await DapTestSession.setUp(forceVerboseLogging: true);
15+
dap = await DapTestSession.setUp();
1816
});
1917
tearDown(() => dap.tearDown());
2018

@@ -57,7 +55,7 @@ main() {
5755
// Run the app and expect it to complete (it should not pause).
5856
final outputEvents = await client.collectOutput(file: testFile);
5957

60-
// Expect error info printed to stderr.
58+
// Expect error info sent to stdout via `print()`.
6159
final output = outputEvents
6260
.where((e) => e.category == 'stdout')
6361
.map((e) => e.output)

0 commit comments

Comments
 (0)