import { status as GrpcStatus } from '@grpc/grpc-js'; /** * gRPC status codes for which subscription operations should be retried. * * Includes both: * 1. GCP-documented retryable errors (DEADLINE_EXCEEDED, RESOURCE_EXHAUSTED, INTERNAL, UNAVAILABLE) * 2. Eventual consistency errors common after Terraform deployments (NOT_FOUND, PERMISSION_DENIED) * * **Why PERMISSION_DENIED is included:** * After Terraform deployments, IAM permissions can take several minutes to propagate across * GCP's distributed infrastructure. During this window, the subscription may report * PERMISSION_DENIED even though permissions are correctly configured. * * **Why NOT_FOUND is included:** * Similar to PERMISSION_DENIED, newly created subscriptions may not be immediately visible * across all GCP endpoints due to eventual consistency. * * @see https://cloud.google.com/pubsub/docs/reference/error-codes * @see https://github.com/googleapis/nodejs-pubsub/issues/979 */ export declare const RETRYABLE_GRPC_STATUS_CODES: readonly [GrpcStatus.DEADLINE_EXCEEDED, GrpcStatus.NOT_FOUND, GrpcStatus.PERMISSION_DENIED, GrpcStatus.RESOURCE_EXHAUSTED, GrpcStatus.INTERNAL, GrpcStatus.UNAVAILABLE]; export type RetryableGrpcStatusCode = (typeof RETRYABLE_GRPC_STATUS_CODES)[number]; /** * Type for errors with a numeric gRPC status code and message. */ export type GrpcError = { code: number; message: string; }; /** * Checks if an error has gRPC error properties (code and message). * Uses duck typing to avoid fragile instanceof checks. * * @param error - The error to check * @returns true if the error has numeric `code` and string `message` properties */ export declare function isGrpcError(error: unknown): error is GrpcError; /** * Checks if an error is a gRPC error with a retryable status code. * * @param error - The error to check * @returns true if the error has a retryable gRPC status code */ export declare function isRetryableGrpcError(error: unknown): error is GrpcError; /** * Gets the gRPC status code from an error if it has one. * * @param error - The error to extract the code from * @returns The gRPC status code, or undefined if not a gRPC error */ export declare function getGrpcStatusCode(error: unknown): number | undefined; export { GrpcStatus };