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

Successfully closing connection logs PSQLError #411

Open
slashmo opened this issue Sep 30, 2023 · 0 comments
Open

Successfully closing connection logs PSQLError #411

slashmo opened this issue Sep 30, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@slashmo
Copy link
Sponsor

slashmo commented Sep 30, 2023

Describe the bug

When successfully closing a connection, PostgresNIO includes a misleading "error" in its log statement.

To Reproduce

Steps to reproduce the behavior:

  1. Set a breakpoint in PostgresChannelHandler: https://github.com/vapor/postgres-nio/blob/1.18.1/Sources/PostgresNIO/New/PostgresChannelHandler.swift#L566
  2. Set log level to .trace or .debug
  3. Successfully establish a connection
  4. Close connection using connection.close()
  5. Using LLDB, inspect cleanup.error
  6. Find the log statement: psql_connection_id=0 psql_error=PSQLError – Generic description to prevent accidental leakage of sensitive data. For debugging details, use String(reflecting: error). [PostgresNIO] Cleaning up and closing connection.

Expected behavior

I would expect not to see an error in the log statement when the connection was closed successfully.

Environment

  • PostgresNIO version: 1.18.1
  • OS version: macOS 14.0 (23A344)

Additional context

I can see that closeConnectionAndCleanup already treats the error code clientConnectionClosed a special since it doesn't fire an error for it:

if cleanup.error.code != .clientClosedConnection {

Perhaps the log statement could also conditionally exclude the error metadata if the code is clientConnectionClosed?

@slashmo slashmo added the bug Something isn't working label Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant