DEADLINE_EXCEEDED
gRPCERRORNotableAvailabilityHIGH confidence

The deadline expired before the operation could complete

What this means

Indicates that the RPC completed after the deadline. This can happen if the server takes too long to respond or if the client-specified deadline was too short.

Why it happens
  1. 1The client-specified deadline was too short for the operation to complete.
  2. 2The server is experiencing high latency due to heavy load or slow downstream dependencies.
  3. 3Network latency between the client and server is high.
How to reproduce

A client sets a short deadline for an RPC that requires significant processing time.

trigger — this will error
trigger — this will error
// Client sets a 50ms deadline for a long-running operation
try {
  await client.runComplexReport(request, {
    deadline: Date.now() + 50
  });
} catch (e) {
  // e.code will be grpc.status.DEADLINE_EXCEEDED
}

expected output

StatusCode.DEADLINE_EXCEEDED: The deadline expired before the operation could complete

Fix 1

Increase the Client Deadline

WHEN When the operation is known to be slow.

Increase the Client Deadline
// Give the operation more time to complete
await client.runComplexReport(request, {
  deadline: Date.now() + 10000 // 10 seconds
});

Why this works

Adjusting the deadline to a realistic value prevents the client from giving up prematurely.

Fix 2

Optimize Server-Side Performance

WHEN When the server is consistently slow.

Optimize Server-Side Performance
// Server-side: Profile the RPC handler to find bottlenecks
// Example: Add caching for expensive operations
const cachedResult = await cache.get(reportId);
if (cachedResult) {
  return cachedResult;
}

Why this works

Improving server performance by optimizing code, adding caching, or scaling resources can resolve the issue at its source.

What not to do

Set excessively long or infinite deadlines

This can lead to client resources being held up indefinitely for a non-responsive server, potentially causing resource exhaustion on the client.

Sources

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All gRPC errors