Skip to content

On-connect notices crash connection #495

@dts

Description

@dts

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions