Merged
Conversation
jasonmreding
reviewed
Jan 6, 2026
jasonmreding
approved these changes
Jan 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Server-Side Cancellation Error Code Propagation
Overview
This document describes the changes made to the gRPC-LabVIEW DLL to properly propagate custom error codes from
SetCallStatusthrough to theGetRequestDatafunction, enabling LabVIEW applications to distinguish between normal call completion and server-initiated cancellation.Problem Statement
Previously, when
GetRequestDataexited from a blocking call, it would always return-2regardless of whether the call completed normally or was forcefully cancelled viaSetCallStatus. This made it impossible for LabVIEW code to differentiate between:SetCallStatus)While
SetCallStatuscould force the DLL to exit its blocking state, the calling code in LabVIEW had no way to know why the call ended.Solution
The solution adds error code propagation from
SetCallStatustoGetRequestDataby:GetRequestDatabefore returning the generic-2error-(1000 + statusCode)) when a non-OK status has been setFiles Modified
1.
src/grpc_server.hChange: Added public method declaration to
CallDataclassgrpc::StatusCode GetCallStatusCode();Location: Line 161, in the public section of the
CallDataclass declarationPurpose: Provides public access to the internal
_callStatuserror code2.
src/event_data.ccChange: Implemented the
GetCallStatusCode()methodLocation: After the
SetCallStatusErrormethods (around line 81-86)Purpose: Returns the status code from the internal
_callStatusmember variable3.
src/grpc_interop.ccChange: Modified
GetRequestDatato check for custom error status before returning-2Original code:
New code:
Location: In the
GetRequestDatafunction, lines 390-396Purpose: Before returning the generic
-2error, checks if a custom status was set viaSetCallStatusand returns that error code insteadHow It Works
Normal Flow (No Custom Error)
GetRequestDatais called and blocks waiting for dataIsActive()returns false andReadNext()returns falseGetCallStatusCode()returnsgrpc::StatusCode::OK(0)-2(normal completion)Custom Error Flow (Server-Side Cancellation)
GetRequestDatais called and blocks waiting for dataSetCallStatus(id, errorCode, "message")from another thread_callStatusto the specified error code and breaks the blocking callIsActive()returns false andReadNext()returns falseGetCallStatusCode()returns the custom error code (e.g.,grpc::StatusCode::CANCELLED= 1)-(1000 + errorCode)(e.g.,-1001for CANCELLED)Usage in LabVIEW
Example: Detecting Server-Side Cancellation
Example: Cancelling from Another Thread
Error Code Reference
The error codes follow the pattern:
-(1000 + grpc::StatusCode)Common error codes:
0: Success (data received)-1: Invalid call ID-2: Normal completion (no custom error)-1001:-(1000 + CANCELLED)- Server-side cancellation-1002:-(1000 + UNKNOWN)- Unknown error-1004:-(1000 + DEADLINE_EXCEEDED)- Timeout-1013:-(1000 + INTERNAL)- Internal errorSee gRPC Status Codes for complete list.
Benefits
DEADLINE_EXCEEDEDstatusSetCallStatuswill still receive-2as beforeTesting
The .DLL was built and tested on an existing grpc-labview project. Previously the stream would exit with -2 on the server regardless of the reason. Now it exits with the reason you give it.