@ikonintegration/ikapi 2.6.5-beta2 → 2.6.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonintegration/ikapi",
3
- "version": "2.6.5-beta2",
3
+ "version": "2.6.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "main.js",
@@ -104,14 +104,16 @@ export default class IKCache_Redis extends IKCache {
104
104
  localConsole.debug("Starting remote cache connection");
105
105
 
106
106
  //Instantiate client and initiate connection
107
- return new Promise((resolve, reject) => {
107
+ return new Promise(async (resolve, reject) => {
108
108
  const redis = require("redis");
109
109
  const isV4 = this._isRedisClientV4();
110
110
  //
111
111
  const connection = redis.createClient({
112
112
  ...(isV4 ? {
113
- username: this.config.user, url: this.config.host,
114
- ...(this.config.enableTLS ? { socket: { tls: true } } /* https://docs.upstash.com/howto/connectwithtls */ : {})
113
+ username: this.config.user,
114
+ socket: {
115
+ ...(this.config.enableTLS ? { tls: true } : {}), host: this.config.host
116
+ }
115
117
  } : {
116
118
  host: this.config.host, user: this.config.user,
117
119
  ...(this.config.enableTLS ? { tls: {} } /* https://docs.upstash.com/howto/connectwithtls */ : {})
@@ -121,12 +123,14 @@ export default class IKCache_Redis extends IKCache {
121
123
  //redis v4 & v3 compatibility
122
124
  if (connection && connection.connect) await connection.connect();
123
125
  //
124
- connection.on('connect', () => {
126
+ connectedHandler = () => {
125
127
  this.connection = connection;
126
128
  if (this.awaitingConnectionQueue) this.awaitingConnectionQueue.forEach((resolve) => resolve());
127
129
  this.awaitingConnectionQueue = null;
128
130
  resolve();
129
- });
131
+ }
132
+ connection.on('connect', connectedHandler);
133
+ if (isV4) connectedHandler(); //reached here on v4, everything is connected
130
134
  connection.on('error', (err) => {
131
135
  localConsole.error(err);
132
136
  if (this.awaitingConnectionQueue) this.awaitingConnectionQueue.forEach((resolve) => resolve()); //fulfill, error will be thrown