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

On-connect notices crash connection #495

Open
dts opened this issue Jan 2, 2025 · 3 comments
Open

On-connect notices crash connection #495

dts opened this issue Jan 2, 2025 · 3 comments

Comments

@dts
Copy link
Contributor

dts commented Jan 2, 2025

Describe the bug

When postgres returns a notice as part of connection, the connection is terminated with this Error: "Error: Unknown response for startup: N".

To Reproduce

Get a postgres instance that has some misconfiguration (in my case, the notice is: "SWARNING�VWARNING�C42602�Minvalid configuration parameter name "supautils.policy_grants", removing it�D"supautils" is now a reserved prefix.�Fguc.c�L9729�RMarkGUCPrefixReserved")

Expected behavior

It should just log the notice and continue.

Additional context

If applicable, add any other context about the problem here.

  • deno-postgres version: 19.3.
  • deno version: 0.43?

To fix, all I had to do was add a NOTICE type:

export const INCOMING_AUTHENTICATION_MESSAGES = {
  AUTHENTICATION: "R",
  BACKEND_KEY: "K",
  PARAMETER_STATUS: "S",
  READY: "Z",
  NOTICE: "N",
} as const;

And just log the thing instead of crashing:

  case INCOMING_AUTHENTICATION_MESSAGES.PARAMETER_STATUS:
            break;
          case INCOMING_AUTHENTICATION_MESSAGES.NOTICE:
            console.warn("NOTICE: ", new TextDecoder().decode(message.body));
            break;
          default:
            throw new Error(`Unknown response for startup: ${message.type}`);
        }

Hope that's helpful!

@dts
Copy link
Contributor Author

dts commented Jan 2, 2025

If helpful, I can post a PR

@bombillazo
Copy link
Collaborator

Sure thing

@dts
Copy link
Contributor Author

dts commented Jan 3, 2025

@bombillazo - done.

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