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

Avoid console.error (throw if needed) #404

Closed
jtoppine opened this issue Oct 4, 2023 · 1 comment · Fixed by #409
Closed

Avoid console.error (throw if needed) #404

jtoppine opened this issue Oct 4, 2023 · 1 comment · Fixed by #409

Comments

@jtoppine
Copy link

jtoppine commented Oct 4, 2023

Library outputting to the console is undesireable in most cases.

In cluster.ts, the close function looks like this:

close() {
    for (const conn of this.#connections) {
      try {
        conn.close();
      } catch (error) {
        console.error(`Error closing connection: ${error}`);
      }
    }
  }

The error should be thrown if it's important for users to be able to handle the situation. Or ignored as this looks like something that is safe to ignore.

Most likely this is just from attempting to close an already closed connection, and just a no-op might be correct way to handle it (?).

In any case logging to the console is bad. For example, I'm running the code in a subprocess which only outputs JSON to be consumed elsewhere - random console outputs messes up the parsing in the receiving end.

@erfanium
Copy link
Member

erfanium commented Oct 5, 2023

@jtoppine Thanks for reporting this, could you open a PR to resolve this issue?

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

Successfully merging a pull request may close this issue.

2 participants