gRPC

gRPC 1 CANCELLED vs 2 UNKNOWN

Both gRPC 1 (CANCELLED) and 2 (UNKNOWN) belong to the gRPC Status Codes category. 1 indicates that the operation was cancelled, typically by the caller. Meanwhile, 2 means that an unknown error occurred. This may be returned when a server raises an exception that doesn't map to any known gRPC status code.

Deskripsi

The operation was cancelled, typically by the caller.

Ketika Anda Melihatnya

The client explicitly cancelled the RPC, or a deadline or context cancellation propagated to the server before it could finish processing.

Cara Memperbaiki

If unexpected, check whether the client is setting too-short deadlines or if cancellation is being triggered inadvertently in your call chain.

Deskripsi

An unknown error occurred. This may be returned when a server raises an exception that doesn't map to any known gRPC status code.

Ketika Anda Melihatnya

The server threw an unhandled exception or returned an error that gRPC couldn't classify into a more specific status code.

Cara Memperbaiki

Check the server logs for the underlying exception. Wrap server-side errors with explicit gRPC status codes instead of letting them bubble up as UNKNOWN.

Perbedaan Utama

1.

gRPC 1: The operation was cancelled, typically by the caller.

2.

gRPC 2: An unknown error occurred. This may be returned when a server raises an exception that doesn't map to any known gRPC status code.

3.

You encounter 1 when the client explicitly cancelled the RPC, or a deadline or context cancellation propagated to the server before it could finish processing.

4.

You encounter 2 when the server threw an unhandled exception or returned an error that gRPC couldn't classify into a more specific status code.

Kapan Menggunakan Yang Mana

For 1 (CANCELLED): If unexpected, check whether the client is setting too-short deadlines or if cancellation is being triggered inadvertently in your call chain. For 2 (UNKNOWN): Check the server logs for the underlying exception. Wrap server-side errors with explicit gRPC status codes instead of letting them bubble up as UNKNOWN.

Pelajari Lebih Lanjut