An internal server error occurred
Indicates the server encountered an unexpected internal error. This code is reserved for serious, unrecoverable server-side issues.
- 1The server experienced a crash or panic while processing the request.
- 2A critical server-side invariant was violated.
- 3A downstream service that is essential for the operation returned a critical error.
The server-side RPC handler encounters a condition it cannot handle, such as a corrupt data structure.
// Server-side: an unexpected and serious error occurs
async myMethod(call, callback) {
// This should not happen and indicates a bug or data corruption.
if (isSystemInCorruptState()) {
callback({
code: grpc.status.INTERNAL,
details: "Critical invariant violated."
});
}
}expected output
StatusCode.INTERNAL: An internal server error occurred
Fix 1
Inspect Server Logs for Severe Errors
WHEN Immediately after receiving an INTERNAL error.
// Check server logs for panic, segmentation fault, or out-of-memory errors. // Look for logs indicating a critical failure. grep "FATAL|PANIC" /var/log/my-service.log
Why this works
INTERNAL errors are usually accompanied by detailed server-side logs that are essential for debugging the underlying bug.
Fix 2
Consider a Limited Retry with Backoff
WHEN If the internal error might be transient (e.g., a server crashing and restarting).
// Retry cautiously, as the error might be persistent.
try {
return await client.myMethod(request);
} catch (e) {
if (e.code === grpc.status.INTERNAL) {
// Wait and try once more in case it was a server crash.
await sleep(1000);
return await client.myMethod(request);
}
}Why this works
A limited, delayed retry can sometimes succeed if the error was caused by a server that was in the process of crashing and restarting.
✕ Assume it's a transient issue and retry aggressively
INTERNAL errors often point to serious bugs. Aggressive retries can exacerbate the problem or hide the underlying issue.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev