Skip to content

Commit 196372c

Browse files
committed
[green] keep failed physical retirements fail closed
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent 76c831b commit 196372c

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎app/lib/pble/connection_manager.dart‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,14 @@ class PbleConnectionManager implements ConnectionManager {
336336
Future<void> _retire(Connection board) {
337337
final Future<void> closing = Future<void>.sync(board.dispose);
338338
_retirements.add(closing);
339-
// The original future retains any error for its owning operation; this
340-
// bookkeeping branch must not create a second unhandled error future.
339+
// Remove only successful retirements. A failed physical close is not proof
340+
// that another link can safely be opened; later operations must still see
341+
// that failure. Consume this bookkeeping branch's error without replacing
342+
// the original future or issuing an automatic disconnect retry.
341343
unawaited(
342344
closing.then<void>(
343345
(_) => _retirements.remove(closing),
344-
onError: (Object _, StackTrace __) => _retirements.remove(closing),
346+
onError: (Object _, StackTrace _) {},
345347
),
346348
);
347349
return closing;

‎app/test/unit/owned_connection_lifecycle_test.dart‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import 'dart:async';
55
import 'dart:convert';
6-
import 'dart:typed_data';
76

87
import 'package:flutter/foundation.dart';
98
import 'package:flutter_test/flutter_test.dart';
@@ -121,8 +120,9 @@ Future<({PbleConnection connection, _OwnedLink link})> _ready() async {
121120
await pumpEventQueue();
122121
expect(connection.state.value, ConnState.ready);
123122
addTearDown(() async {
124-
if (link.closeGate case final Completer<void> gate when !gate.isCompleted)
123+
if (link.closeGate case final Completer<void> gate when !gate.isCompleted) {
125124
gate.complete();
125+
}
126126
try {
127127
await connection.dispose();
128128
} catch (_) {}

0 commit comments

Comments
 (0)