Error Handling
When working with gRPC streams for Solana CoreCast, you may encounter errors. This page documents common error types, their causes, and how to debug them.
Unauthorizedβ
Code: 16 (UNAUTHENTICATED)
HTTP Status: 401 Unauthorized
Causesβ
- Access token is missing from
config.yaml
. - Access token is incorrect (typo, bad copy-paste).
- Access token is expired or revoked.
Example Outputβ
{
"code": 16,
"details": "Received HTTP status code 401"
}
How to Fixβ
-
Ensure
config.yaml
includes a valid token:server:
address: "corecast.bitquery.io"
authorization: "ory_at_<YOUR_TOKEN>"
insecure: false -
Check for trailing spaces or missing quotes.
-
Generate a new token if expired.
Unsupported Stream Typeβ
Details: Error message will mention unsupported stream type.
Causeβ
The config.stream.type
in config.yaml
refers to a stream that isnβt available with Bitquery gRPC streams.
Example Configβ
stream:
type: "dex_trades" # β
supported
Supported Stream Typesβ
How to Fixβ
- Double-check spelling of the stream type.
- Only use supported values listed above.
- Update your config if the API evolves.
Runtime Errorsβ
Runtime errors can occur for many reasons, including:
- Network connectivity issues.
- Server-side failures (temporary outage, overload).
- Incorrect filters in your request object.
- Message parsing or serialization errors.
Debugging Methodβ
To properly investigate runtime errors, add an error handler to your stream:
stream.on('error', (error) => {
flushLogs();
console.error('Stream error:', error);
console.error('Error details:', error.details);
console.error('Error code:', error.code);
console.error('Request sent:', JSON.stringify(request, null, 2));
});
This will log the full error object, its details, the numeric error code, and the request you sent. With this context, you can narrow down whether the issue is related to authentication, filters, or transient server/network conditions.
Best Practicesβ
- Always log
error.code
anderror.details
. - Use retries with exponential backoff for network issues.
- Validate stream type and filters before starting.
- Rotate tokens regularly and handle token expiry gracefully.