usebruno/bruno · error · Error
Failed to create client
Error message
Failed to create client
What it means
Defensive guard after constructing a gRPC client via makeGenericClientConstructor({}). The constructor essentially always returns a client instance, so this branch is effectively dead code; if hit, it indicates the grpc-js factory returned null/undefined for an internal reason.
Source
Thrown at packages/bruno-requests/src/grpc/grpc-client.js:666
// Extract user-agent from headers if provided (case-insensitive)
// Set it as grpc.primary_user_agent channel option to prepend to the default user-agent
const userAgentKey = Object.keys(request.headers).find(
(key) => key.toLowerCase() === 'user-agent'
);
const userAgentValue = userAgentKey ? request.headers[userAgentKey] : null;
// Resolve proxy target and channel options
const { targetHost, proxyChannelOptions } = this.#resolveProxyTarget(host, proxyConfig);
const mergedChannelOptions = { ...channelOptions, ...proxyChannelOptions };
if (userAgentValue && !channelOptions?.['grpc.primary_user_agent']) {
mergedChannelOptions['grpc.primary_user_agent'] = userAgentValue;
}
const Client = makeGenericClientConstructor({});
const client = new Client(targetHost, credentials, mergedChannelOptions);
if (!client) {
throw new Error('Failed to create client');
}
let messages = request.body.grpc;
try {
messages = messages.map(({ content }) => safeJsonParse(content, 'message content'));
} catch (parseError) {
console.error('Failed to parse gRPC message content:', parseError);
client.close();
this.eventCallback('grpc:error', request.uid, collection.uid, {
error: parseError
});
return; // Exit early to prevent sending invalid data
}
const requestPath = path + methodPath;
const requestId = request.uid;
const collectionUid = collection.uid;
const metadata = new Metadata();View on GitHub (pinned to 9bdd81c7bd)
Solutions
- Treat as an internal invariant violation: reinstall node_modules and ensure @grpc/grpc-js is a supported version.
- If seen in tests, check that makeGenericClientConstructor is not mocked to return undefined.
Defensive patterns
Strategy: try-catch
Try / catch
const client = new Client(targetHost, credentials, mergedChannelOptions);
if (!client || typeof client.makeUnaryRequest !== 'function') throw new Error('Failed to create client'); Prevention
- Pin a known-good @grpc/grpc-js version.
- Do not mock makeGenericClientConstructor to return falsy in tests.
When it happens
Trigger: makeGenericClientConstructor returned a falsy value when invoked with an empty service definition object, which under normal grpc-js operation does not occur.
Common situations: Practically unreachable. Theoretically a broken grpc-js build, a monkeypatched global, or a stubbed makeGenericClientConstructor in tests could trigger it.
Related errors
- Invalid collection format: ${format}
- Failed to parse ${context}: ${error.message}
- Method ${path} not found, please refresh the methods
- Unsupported method type: ${methodType}
- Failed to refresh methods and method ${methodPath} not found
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/a255a152e88b03f7.
Report an issue: GitHub.