{"record":{"id":"9682097ebac9d4ae","repo":"alibaba/nacos","slug":"500-968209","errorCode":"500","errorMessage":"{}","messagePattern":"\\{\\}","errorType":"exception","errorClass":"NacosException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/com/alibaba/nacos/common/remote/client/grpc/GrpcConnection.java","lineNumber":81,"sourceCode":"    \n    public GrpcConnection(RpcClient.ServerInfo serverInfo, Executor executor) {\n        super(serverInfo);\n        this.executor = executor;\n    }\n    \n    @Override\n    public Response request(Request request, long timeouts) throws NacosException {\n        Payload grpcRequest = GrpcUtils.convert(request);\n        ListenableFuture<Payload> requestFuture = grpcFutureServiceStub.request(grpcRequest);\n        Payload grpcResponse;\n        try {\n            if (timeouts <= 0) {\n                grpcResponse = requestFuture.get();\n            } else {\n                grpcResponse = requestFuture.get(timeouts, TimeUnit.MILLISECONDS);\n            }\n        } catch (Exception e) {\n            throw new NacosException(NacosException.SERVER_ERROR, e);\n        }\n        \n        return (Response) GrpcUtils.parse(grpcResponse);\n    }\n    \n    @Override\n    public RequestFuture requestFuture(Request request) throws NacosException {\n        Payload grpcRequest = GrpcUtils.convert(request);\n        \n        final ListenableFuture<Payload> requestFuture = grpcFutureServiceStub.request(grpcRequest);\n        return new RequestFuture() {\n            \n            @Override\n            public boolean isDone() {\n                return requestFuture.isDone();\n            }\n            \n            @Override","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/common/src/main/java/com/alibaba/nacos/common/remote/client/grpc/GrpcConnection.java#L63-L99","documentation":"GrpcConnection.request() wraps any exception thrown while waiting on the gRPC ListenableFuture (timeout, cancellation, channel error, interrupted) into a NacosException with SERVER_ERROR (500) and the original exception as its cause. The literal message is the exception's own toString via the NacosException(Throwable) constructor.","triggerScenarios":"Calling request() through the connection and the gRPC future.get()/get(timeout) throws: TimeoutException (deadline exceeded), InterruptedException, ExecutionException (server-side failure surfaced through the future), or CancellationException.","commonSituations":"Server slow to respond so the timeoutMills deadline is exceeded; server-side handler threw (ExecutionException wraps it); channel went unhealthy between send and receive; client thread interrupted; gRPC deadline/cancellation propagated.","solutions":["Increase the per-request timeout passed to request() if timeouts dominate.","Inspect the wrapped cause (NacosException.getCause()) to distinguish timeout vs server error vs interruption.","For server-side failures, check the Nacos server log for the corresponding request handler exception.","For interruptions, ensure the calling thread is not being prematurely interrupted and handle InterruptedException cleanly."],"exampleFix":"// before — fixed short timeout causing frequent timeouts\nResponse r = connection.request(req, 500);\n\n// after — timeout sized to the operation, plus cause inspection\ntry {\n    Response r = connection.request(req, 5000);\n} catch (NacosException ne) {\n    Throwable cause = ne.getCause(); // TimeoutException? ExecutionException?\n}","handlingStrategy":"try-catch","validationCode":"static Response requestWithAdequateTimeout(GrpcConnection conn, Request req, long timeout) throws NacosException {\n    if (timeout <= 0) throw new IllegalArgumentException(\"timeout must be positive\");\n    return conn.request(req, timeout);\n}","typeGuard":null,"tryCatchPattern":"try {\n    response = connection.request(req, timeout);\n} catch (NacosException ne) {\n    Throwable cause = ne.getCause();\n    if (cause instanceof TimeoutException) {\n        // increase timeout or back off and retry\n    } else if (cause instanceof ExecutionException) {\n        // server-side failure — check server logs\n    } else { throw ne; }\n}","preventionTips":["Size request timeouts to the operation's expected latency plus margin.","Inspect NacosException.getCause() to distinguish timeout vs server error vs interruption.","Do not swallow InterruptedException — restore the interrupt status and exit cleanly."],"tags":["grpc","connection","timeout","server-error","transport"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}