Skip to content

server and port properties are required when using the custom connector factory method #1541

@ruyadorno

Description

@ruyadorno

Software versions

  • Tedious: 16.1.0
  • Node.js: 16+

Additional Libraries Used and Versions

Particularly noticeable when using alongside the @google-cloud/cloud-sql-connector library that uses the connector factory method.

Connection configuration

Notice the highlighted properties that should not be required, since a custom connector function is being used:

const connection = new Connection({
-  server: '0.0.0.0',
  authentication: {
    type: 'default',
    options: {
      userName: process.env.SQLSERVER_USER,
      password: process.env.SQLSERVER_PASS,
    },
  },
  options: {
    connector: async () => net.connect({
      host: '192.168.1.212',
      port: 1433,
    }),
-    port: 9999,
    database: process.env.SQLSERVER_DB,
  },
})

Problem description

When using the new custom connector factory method, the server and port properties should not be required.

Expected behavior

Config options defining only a connector factory method should be valid.

Actual behavior

Error message/stack trace

The "config.server" property is required and must be of type string.

  test: open connection and run basic sqlserver commands
  stack: |
    new Connection (node_modules/tedious/src/connection.ts:1056:13)
    Test.<anonymous> (system-test/tedious-connect.cjs:30:24)
  at:
    line: 1056
    column: 13
    file: node_modules/tedious/src/connection.ts
    function: Connection

Any other details that can be helpful

Please note that I'm the original contributor of that feature and will be happy to follow up with a fix for this problem 😊

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