Closed
Description
Flutter
Flutter 3.27.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 68415ad1d9 (11 days ago) • 2025-01-13 10:22:03 -0800
Engine • revision e672b006cb
Tools • Dart 3.6.1 • DevTools 2.40.2
Problem
Pool does not handle network cable break properly. Native error pass try/catch when network break occurs while there are no executing connections in pool.
Steps to reproduce
- Connect PC with ethernet cable.
- Run attached program (replace endpoint args with non-local postges's credentials).
- Let execute sql couple times.
- On prompt
try disconnect cable in 10 seconds...
: disconnect ethernet cable. - Loop should continue, but program fails with uncatched error.
Program
pubspec.yaml
name: postgres_exploit
description: postgres_exploit
version: 1.0.0
publish_to: none
environment:
sdk: ^3.6.1
dependencies:
postgres: ^3.0.0
dev_dependencies:
lints: ^4.0.0
test: ^1.24.0
postgres_exploit.dart:
import 'package:postgres/postgres.dart';
Future<void> main(List<String> arguments) async {
final pool = Pool.withSelector(
(context) async => EndpointSelection(
endpoint: Endpoint(
host: 'host.com',
port: 5432,
database: 'postgres',
username: 'user',
password: 'password',
)),
settings: PoolSettings(sslMode: SslMode.disable, maxConnectionCount: 1),
);
while (true) {
print('----- ${DateTime.now()}');
final result = await pool
.execute(Sql.named('SELECT pg_sleep(1), version()'))
.then(
(result) => 'OK: ${result.first}',
)
.onError(
(error, stackTrace) {
print('Error: $error, $stackTrace');
return '$error';
},
);
print('Result: $result');
print('try disconnect cable in 10 seconds...');
await Future.delayed(Duration(seconds: 10));
}
}
C:/Programs/flutter/bin/cache/dart-sdk/bin/dart.exe --enable-asserts --no-serve-devtools D:\work\flutter\postgres_exploit\lib\postgres_exploit.dart
----- 2025-01-24 21:01:25.457665
Result: OK: [null, PostgreSQL 13.16 on x86_64-pc-linux-gnu, compiled by Debian clang version 12.0.1, 64-bit]
try disconnect cable in 10 seconds...
----- 2025-01-24 21:01:37.435116
Result: OK: [null, PostgreSQL 13.16 on x86_64-pc-linux-gnu, compiled by Debian clang version 12.0.1, 64-bit]
try disconnect cable in 10 seconds...
----- 2025-01-24 21:01:48.873554
Unhandled exception:
type '(Object, StackTrace) => void' is not a subtype of type '(dynamic) => dynamic' in type cast
#0 _CancelOnErrorSubscriptionWrapper.onError.<anonymous closure>.<anonymous closure> (package:async/src/subscription_stream.dart:82:24)
#1 _RootZone.run (dart:async/zone.dart:1670:54)
#2 _FutureListener.handleWhenComplete (dart:async/future_impl.dart:247:18)
#3 Future._propagateToListeners.handleWhenCompleteCallback (dart:async/future_impl.dart:872:39)
#4 Future._propagateToListeners (dart:async/future_impl.dart:928:11)
#5 Future._addListener.<anonymous closure> (dart:async/future_impl.dart:513:9)
#6 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#7 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#8 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#9 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)
Process finished with exit code 255
Metadata
Metadata
Assignees
Labels
No labels