RESOURCE_EXHAUSTED
gRPCERRORCriticalAvailabilityHIGH confidence

Some resource has been exhausted

What this means

Indicates some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. This suggests a scalability or quota issue.

Why it happens
  1. 1A rate limit or API quota for the user has been exceeded.
  2. 2The server has run out of a system resource, such as disk space or memory.
  3. 3A server-side resource pool (e.g., database connections) has been depleted.
How to reproduce

A client exceeds their daily API call quota.

trigger — this will error
trigger — this will error
// Client makes many requests in a short period
for (let i = 0; i < 1000; i++) {
  try {
    await client.doWork(request);
  } catch (e) {
    if (e.code === grpc.status.RESOURCE_EXHAUSTED) {
      // Quota likely exceeded
      break;
    }
  }
}

expected output

StatusCode.RESOURCE_EXHAUSTED: Some resource has been exhausted

Fix 1

Implement Client-Side Rate Limiting with Backoff

WHEN When the error is due to exceeding a rate limit.

Implement Client-Side Rate Limiting with Backoff
// Implement exponential backoff after hitting a rate limit
catch (e) {
  if (e.code === grpc.status.RESOURCE_EXHAUSTED) {
    // The server is telling us to slow down.
    await sleep(5000); // Wait 5 seconds before next attempt
  }
}

Why this works

By waiting before retrying, the client respects the server's limits and avoids making the problem worse.

Fix 2

Increase Server Quotas or Scale Resources

WHEN When the exhausted resource is on the server.

Increase Server Quotas or Scale Resources
// This is an administrative or infrastructure change.
// Example: Increase disk size on the server machine.
// Example: Request a higher API quota from the service provider.

Why this works

If legitimate usage is hitting resource limits, the limits need to be increased by scaling up server resources or adjusting quotas.

What not to do

Immediately retry the request

The server is explicitly stating it cannot handle the request due to a lack of resources. Retrying immediately will only increase the load and prolong the issue.

Sources

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

← All gRPC errors