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

Conversation

HBashanaE
Copy link

@HBashanaE HBashanaE commented Apr 17, 2024

Remove console.error on 429, not to log error on client side even if the errors are handled.

As per @buffalojoec 's suggestion, parameterized the log.

Copy link

changeset-bot bot commented Apr 17, 2024

⚠️ No Changeset found

Latest commit: a7092df

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mergify mergify bot added the community label Apr 17, 2024
@mergify mergify bot requested a review from a team April 17, 2024 13:14
@rangatechnologies
Copy link

Remove console.error on 429, not to log error on client side even if the errors are handled.

Yes i am also facing with same issue, this is fundamental. Please remove this.

Copy link
Collaborator

@buffalojoec buffalojoec left a comment

Choose a reason for hiding this comment

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

I think there's maybe a better way to do this. Some developers may actually like and/or depend on this message in their app somehow.

What about plumbing a config through Connection that can allow you to disable this log message (and likely others)? Something like noLog: true, maybe?

@HBashanaE
Copy link
Author

@buffalojoec Make sense. Let's do like that.

Co-authored-by: Joe C <joecaulfield29@yahoo.com>
Copy link
Collaborator

@buffalojoec buffalojoec left a comment

Choose a reason for hiding this comment

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

Cool! But you can't actually access that parameter. This function is private and needs to be invoked by the Connection class.

this._rpcClient = createRpcClient(
endpoint,
httpHeaders,
fetch,
fetchMiddleware,
disableRetryOnRateLimit,
httpAgent,
);

Copy link
Collaborator

@buffalojoec buffalojoec left a comment

Choose a reason for hiding this comment

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

Great, thanks! I think if we're going to add this parameter, let's use it everywhere else there's a console output someone might want to disable. There's a handful more around the Connection class that can use this feature.

Copy link
Collaborator

@steveluscher steveluscher left a comment

Choose a reason for hiding this comment

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

At this point, I think I'm unlikely to accept this change unless you can explain more about the problem.

Yes i am also facing with same issue, this is fundamental.

Other than the log being annoying, is there any other issue? I'm looking for something that affects the operation of your app.

Console logs were never the right thing to do here, but we're here now, and I see only downsides to making a change now.

  • This will break any developers who are spying on console.error and depend on the ability to scrutinize this log
  • Adding config is always bad
    • every bit of config is cognitive overhead for the developer (log what? log to where? log, as opposed to what?)
    • when the config is switched off you still bundle the code – now dead code – controlled by that config. The right way to do config like this is by replacing constants, statically, at build time, so that the build system can reap the dead branches of code.

@@ -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.

Copy link
Collaborator

I'm going to close this PR at this time; if you have time to revisit this and answer the question above, we can pick it up again!

Copy link
Contributor

mergify bot commented May 8, 2024

⚠️ The sha of the head commit of this PR conflicts with #2681. Mergify cannot evaluate rules on this PR. ⚠️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants