From bc01199970fe0fa407dbc5c9dd1f23647e4b174e Mon Sep 17 00:00:00 2001 From: Siting Ren Date: Tue, 5 Mar 2024 11:52:00 +0800 Subject: [PATCH] Fix #136 (#138) --- .../lib/connection-parameters.js | 28 ++++++++++++++++--- .../client/connection-timeout-tests.js | 2 +- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/packages/vertica-nodejs/lib/connection-parameters.js b/packages/vertica-nodejs/lib/connection-parameters.js index 5b874dbf..fa276ff9 100644 --- a/packages/vertica-nodejs/lib/connection-parameters.js +++ b/packages/vertica-nodejs/lib/connection-parameters.js @@ -116,12 +116,32 @@ class ConnectionParameters { this.workload = val('workload', config, false) // client auditing information - this.client_os_hostname = os.hostname() this.client_type = "Node.js Driver" this.client_version = "1.1.2" - this.client_pid = process.pid.toString() - this.client_os = os.platform() - this.client_os_user_name = os.userInfo().username + + try { + this.client_os_hostname = os.hostname() + } catch (e) { + this.client_os_hostname = "" + } + + try { + this.client_pid = process.pid.toString() + } catch (e) { + this.client_pid = "0" + } + + try { + this.client_os = os.platform() + } catch (e) { + this.client_os = "" + } + + try { + this.client_os_user_name = os.userInfo().username + } catch (e) { + this.client_os_user_name = "" + } //NOTE: The client has only been tested to support 3.5, which was chosen in order to include SHA512 support this.protocol_version = (3 << 16 | 5) // 3.5 -> (major << 16 | minor) -> (3 << 16 | 5) -> 196613 diff --git a/packages/vertica-nodejs/test/integration/client/connection-timeout-tests.js b/packages/vertica-nodejs/test/integration/client/connection-timeout-tests.js index 7a3ee444..a462584b 100644 --- a/packages/vertica-nodejs/test/integration/client/connection-timeout-tests.js +++ b/packages/vertica-nodejs/test/integration/client/connection-timeout-tests.js @@ -67,7 +67,7 @@ suite.test('successful connection', (done) => { }) suite.test('expired connection timeout', (done) => { - const opts = { ...options, port: 54322 } + const opts = { ...options, port: 5434 } serverWithConnectionTimeout(opts.port, opts.connectionTimeoutMillis * 2, (closeServer) => { const timeoutId = setTimeout(() => { throw new Error('Client should have emitted an error but it did not.')