rpcserver: attempt to fix uncaught exception.

Rebased-From: f9c571aad8261eb9a5cab9dce5b490bd253c5fe1
Github-Pull: #5565