Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove console.error #2511

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions packages/library-legacy/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,7 @@ function createRpcClient(
fetchMiddleware?: FetchMiddleware,
disableRetryOnRateLimit?: boolean,
httpAgent?: NodeHttpAgent | NodeHttpsAgent | false,
log = true,
): RpcClient {
const fetch = customFetch ? customFetch : fetchImpl;
let agent: NodeHttpAgent | NodeHttpsAgent | undefined;
Expand Down Expand Up @@ -1635,9 +1636,12 @@ function createRpcClient(
if (too_many_requests_retries === 0) {
break;
}
console.error(
`Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`,
);
if(log){
console.error(
`Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`,
);
}

await sleep(waitTime);
waitTime *= 2;
}
Expand Down Expand Up @@ -3119,6 +3123,7 @@ export class Connection {
constructor(
endpoint: string,
commitmentOrConfig?: Commitment | ConnectionConfig,
log = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A parameter has not been added to the top-level Connection constructor for years; doing so should be done with care, and only in cases where the parameter is fundamental to the nature of the connection instance itself. I don't think this parameter meets that bar.

Also, at this high a level, it won't be obvious to developers what log controls. There are tons of logs in this class, and this only controls one of them, without actually describing that target in the name of the argument.

Related: functions with lists of boolean arguments yield bad outcomes. Read more here.

If this belonged here at all, it belongs on the ConnectionConfig type.

) {
let wsEndpoint;
let httpHeaders;
Expand Down Expand Up @@ -3150,6 +3155,7 @@ export class Connection {
fetchMiddleware,
disableRetryOnRateLimit,
httpAgent,
log
);
this._rpcRequest = createRpcRequest(this._rpcClient);
this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
Expand Down