The operation was cancelled
Indicates the operation was cancelled, typically by the client. This can happen if the client aborts the request or the deadline is exceeded before the server can respond.
- 1The client explicitly cancelled the request before it completed.
- 2A client-side deadline was exceeded before the operation could complete.
- 3The underlying HTTP/2 connection was closed by the client.
A client cancels an ongoing RPC call, for example, due to a user action or a timeout.
const controller = new AbortController();
// Cancel the call after 100ms
setTimeout(() => controller.abort(), 100);
try {
const response = await client.myMethod(request, { signal: controller.signal });
} catch (e) {
// e.code will be grpc.status.CANCELLED
}expected output
StatusCode.CANCELLED: The operation was cancelled
Fix 1
Investigate Client-Side Logic
WHEN When cancellations are unexpected.
// Review the client code for any logic that might cancel the request.
// Check for user-initiated cancellations, timeouts, or race conditions.
function userAction() {
// Is controller.abort() being called prematurely?
controller.abort();
}Why this works
Identify the source of the cancellation signal to determine if it is expected behavior or a bug.
Fix 2
Increase Client-Side Deadlines
WHEN If cancellations are due to premature timeouts for long-running operations.
// Set a longer deadline for the RPC call
const response = await client.myMethod(request, {
deadline: Date.now() + 5000 // 5 seconds
});Why this works
Allow more time for the server to process the request before the client gives up.
✕ Retry automatically without investigation
If the cancellation is intentional (e.g., user clicked a 'cancel' button), retrying the operation goes against the user's intent.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev