wileys 0.4.2 → 0.4.3

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.
@@ -773,7 +773,6 @@ const makeMessagesSocket = (config) => {
773
773
  await relayMessage(jid, mediaMsg.message, {
774
774
  messageId: mediaMsg.key.id
775
775
  });
776
- await new Promise(resolve => setTimeout(resolve, 800));
777
776
  }
778
777
  return albumMsg;
779
778
  }
@@ -89,14 +89,6 @@ const makeSocket = (config) => {
89
89
  // ignore
90
90
  }
91
91
  }
92
- // gently back off when encountering rate limits (429)
93
- if (message.includes('429') || message.includes('rate limit')) {
94
- const wait = Math.min(30000, (config.backoffDelayMs || 5000));
95
- logger.info({ wait }, 'backing off due to rate limit');
96
- setTimeout(() => {
97
- // intentionally empty; wait to delay further sends
98
- }, wait);
99
- }
100
92
  };
101
93
  /** await the next incoming message */
102
94
  const awaitNextMessage = async (sendMsg) => {
@@ -140,7 +132,7 @@ const makeSocket = (config) => {
140
132
  };
141
133
  ws.on(`TAG:${msgId}`, onRecv);
142
134
  ws.on('close', onErr); // if the socket closes, you'll never receive the message
143
- ws.off('error', onErr);
135
+ ws.on('error', onErr);
144
136
  });
145
137
  return result;
146
138
  }
@@ -156,11 +148,13 @@ const makeSocket = (config) => {
156
148
  node.attrs.id = generateMessageTag();
157
149
  }
158
150
  const msgId = node.attrs.id;
159
- const [result] = await Promise.all([
160
- waitForMessage(msgId, timeoutMs),
151
+ const result = await (0, Utils_1.promiseTimeout)(timeoutMs, async (resolve, reject) => {
152
+ const wait = waitForMessage(msgId, timeoutMs).catch(reject);
161
153
  sendNode(node)
162
- ]);
163
- if ('tag' in result) {
154
+ .then(async () => resolve(await wait))
155
+ .catch(reject);
156
+ });
157
+ if (result && 'tag' in result) {
164
158
  (0, WABinary_1.assertNodeErrorFree)(result);
165
159
  }
166
160
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wileys",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "WhatsApp Web API Library",
5
5
  "keywords": [
6
6
  "wileys",