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
Remove console.error #2511
Conversation
|
Yes i am also facing with same issue, this is fundamental. Please remove this. |
There was a problem hiding this 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?
@buffalojoec Make sense. Let's do like that. |
Co-authored-by: Joe C <joecaulfield29@yahoo.com>
There was a problem hiding this 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.
solana-web3.js/packages/library-legacy/src/connection.ts
Lines 3146 to 3153 in d3d5399
this._rpcClient = createRpcClient( | |
endpoint, | |
httpHeaders, | |
fetch, | |
fetchMiddleware, | |
disableRetryOnRateLimit, | |
httpAgent, | |
); |
There was a problem hiding this 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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
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! |
|
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.