Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions thrown without stack traces #729

Open
blaugold opened this issue Aug 16, 2024 · 2 comments
Open

Exceptions thrown without stack traces #729

blaugold opened this issue Aug 16, 2024 · 2 comments

Comments

@blaugold
Copy link

package:grpc uses StreamController.addError and Completer.completeError in a number of places without providing a stack trace. This makes it difficult to debug GrpcErrors.

Repro steps

  1. Clone git clone https://github.com/grpc/grpc-dart
  2. Go to example/helloworld
  3. Apply the following changes:
    diff --git a/example/helloworld/bin/client.dart b/example/helloworld/bin/client.dart
    index 4ec8e8e..deccead 100644
    --- a/example/helloworld/bin/client.dart
    +++ b/example/helloworld/bin/client.dart
    @@ -37,8 +37,9 @@ Future<void> main(List<String> args) async {
           options: CallOptions(compression: const GzipCodec()),
         );
         print('Greeter client received: ${response.message}');
    -  } catch (e) {
    +  } catch (e, s) {
         print('Caught error: $e');
    +    print('Stack trace: $s');
       }
       await channel.shutdown();
     }
    diff --git a/example/helloworld/bin/server.dart b/example/helloworld/bin/server.dart
    index a2b491c..3e920a5 100644
    --- a/example/helloworld/bin/server.dart
    +++ b/example/helloworld/bin/server.dart
    @@ -20,6 +20,7 @@ import 'package:helloworld/src/generated/helloworld.pbgrpc.dart';
     class GreeterService extends GreeterServiceBase {
       @override
       Future<HelloReply> sayHello(ServiceCall call, HelloRequest request) async {
    +    throw UnimplementedError();
         return HelloReply()..message = 'Hello, ${request.name}!';
       }
     }
  4. Start bin/server.dart
  5. Run bin/client.dart

Expected result: Error thrown by package:grcp includes stack trace.

Actual result: Stack trace is empty:

Caught error: gRPC Error (code: 2, codeName: UNKNOWN, message: UnimplementedError, details: [], rawResponse: null, trailers: {})
Stack trace: 
@blaugold
Copy link
Author

@lrhn Looks to me like https://dart-review.googlesource.com/c/sdk/+/380780 would fix this issue. 😊 Is that the case?

@lrhn
Copy link
Contributor

lrhn commented Aug 20, 2024

Seems likely from the description. Let's see if it's something we want to land, and won't break too many fragile tests. For now it seems to work at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants