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 error being logged for invalid options AND please do not make it ever throw an error for this! #2481

Open
dhurtrci opened this issue Mar 8, 2024 · 1 comment

Comments

@dhurtrci
Copy link

dhurtrci commented Mar 8, 2024

I would like the console logging in the code below (in connection_config.js) to be removed.
Also I would ask that this is never made into a thrown error (as is threatened).

if (validOptions[key] !== 1) {
        // REVIEW: Should this be emitted somehow?
        // eslint-disable-next-line no-console
        console.error(
          `Ignoring invalid configuration option passed to Connection: ${key}. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection`
        );
      }

My reasons are that some other libraries (e.g. loopback-connector-mysql) add 'harmless' extra (non MySql/MariaDB) properties to the object passed here (for other purposes) which leads to this error being logged (and the extra properties do not actually cause problems).

Additionally, having this check (and - more alarmingly - threatening to throw an error in future!) means that the code in mysql2 has to be sure to always keep an up-to-date list of options. Additionally it neglects that different versions of MySQL/MariaDB might in fact have a slightly different list of valid options.

My opinion is that the logging (and check of property name validity) should be removed.

@wellwelwel
Copy link
Collaborator

wellwelwel commented Mar 8, 2024

How about a simple option like noWarnings or hideWarnings at the connection level?

That could solve this issue and the #2471.

Do you think that's a bad idea/practice?

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

No branches or pull requests

2 participants