Some resource has been exhausted
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.
- 1A rate limit or API quota for the user has been exceeded.
- 2The server has run out of a system resource, such as disk space or memory.
- 3A server-side resource pool (e.g., database connections) has been depleted.
A client exceeds their daily API call quota.
// 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 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.
// 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.
✕ 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.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev