dartist / redis_client

A high-performance async/non-blocking Redis client for Dart
BSD 2-Clause "Simplified" License
100 stars 29 forks source link

Using client.get on a closed redis server causes uncatchable exception #67

Open rickybassom opened 7 years ago

rickybassom commented 7 years ago

When the Redis Server is closed, after initially connecting, using client.get() causes an uncatchable exception (shown in output):

Example code

import 'dart:async';
import 'package:redis_client/redis_client.dart';

main(List<String> args) {
  conn();
}

conn() async{
  var client = await RedisClient.connect("localhost:6379").catchError((Exception except){
    throw new Exception("Redis localhost:6379 connection failed - " + except.toString());
  });

  const oneSec = const Duration(seconds: 1);
  new Timer.periodic(oneSec, (Timer t) async {
    try{
      String status = await client.get("status");
      print(status);
    }catch(e){
      print(e.toString());
    }

  });
}

Output

Unhandled exception:
SocketException: OS Error: Broken pipe, errno = 32, address = localhost, port = 35980
#0      _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1138)
#1      _microtaskLoop (dart:async/schedule_microtask.dart:41)
#2      _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#3      _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:149)

It could be related to this issue: https://github.com/dart-lang/sdk/issues/17468

tejainece commented 5 years ago

I am getting the same error in sqljocky5 package when a telegram is sent after the mysql server has shutdown. There is no way to catch this error.

I think it is due to a problem in the Dart SDK.

tejainece commented 5 years ago

I have created a Dart SDK issue here: https://github.com/dart-lang/sdk/issues/35995