@scriptdb/client 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +8 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -116,7 +116,7 @@ class ScriptDBClient {
116
116
  parsed.password = "";
117
117
  this.uri = parsed.toString();
118
118
  } catch (e) {
119
- this.uri = normalized;
119
+ this.uri = uri;
120
120
  }
121
121
  this.host = parsed.hostname || "localhost";
122
122
  this.port = parsed.port ? parseInt(parsed.port, 10) : 1234;
@@ -207,6 +207,12 @@ class ScriptDBClient {
207
207
  this._connecting = null;
208
208
  return reject(error);
209
209
  }
210
+ if (!this.client) {
211
+ const error = new Error("Failed to create client socket");
212
+ this.logger?.error?.("Connection failed", error.message);
213
+ this._connecting = null;
214
+ return reject(error);
215
+ }
210
216
  const onError = (err) => {
211
217
  this.logger?.error?.("Client socket error:", err && err.message ? err.message : err);
212
218
  this._handleDisconnect(err);
@@ -217,7 +223,7 @@ class ScriptDBClient {
217
223
  };
218
224
  this.client.on("error", onError);
219
225
  this.client.on("close", onClose);
220
- if (this.socketTimeout > 0) {
226
+ if (this.socketTimeout > 0 && this.client) {
221
227
  this.client.setTimeout(this.socketTimeout);
222
228
  this.client.on("timeout", () => {
223
229
  this.logger?.warn?.("Socket timeout, destroying connection");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scriptdb/client",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Client module resolver for script database",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",