aunubaileys 1.0.19 → 1.0.20

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/README.md CHANGED
@@ -64,6 +64,10 @@ Everything else is pure upstream. When upstream moves, we rebase the patch layer
64
64
 
65
65
 
66
66
 
67
+ ### 🆕 What's new in 1.0.20 / Baru di 1.0.20
68
+
69
+ - ⏳ **Sends survive reconnect blips** — calling `sendMessage` while the connection is re-establishing used to fail instantly with a 428 from the first internal query, and the message was simply lost. `relayMessage` now waits for the transport to reopen (bounded by `connectTimeoutMs`; a permanently closed connection still fails fast, and a wait that expires raises a clear 408). When the connection is open, behaviour is unchanged.
70
+
67
71
  ### 🆕 What's new in 1.0.19 / Baru di 1.0.19
68
72
 
69
73
  - 🛟 **A failed retry request can no longer kill your bot** — the retry-receipt path after a decrypt failure runs fire-and-forget (by design), but its promise had no error handler at all: one failure inside it became an unhandled rejection, and Node's default policy terminates the whole process. It now routes to the standard error handler — logged, contained, and the bot keeps processing messages.
@@ -12,7 +12,7 @@ import { makeNewsletterSocket } from './newsletter.js';
12
12
  export const makeMessagesSocket = (config) => {
13
13
  const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: axiosOptions, patchMessageBeforeSending, cachedGroupMetadata } = config;
14
14
  const sock = makeNewsletterSocket(makeGroupsSocket(config));
15
- const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, sendNode, groupMetadata, groupToggleEphemeral } = sock;
15
+ const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, sendNode, groupMetadata, groupToggleEphemeral, ws, waitForSocketOpen } = sock;
16
16
  const userDevicesCache = config.userDevicesCache ||
17
17
  new NodeCache({
18
18
  stdTTL: DEFAULT_CACHE_TTLS.USER_DEVICES, // 5 minutes
@@ -269,6 +269,20 @@ export const makeMessagesSocket = (config) => {
269
269
  return { nodes, shouldIncludeDeviceIdentity };
270
270
  };
271
271
  const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }) => {
272
+ if (!ws.isOpen) {
273
+ // AunuBaileys: a send attempted during a reconnect window used to die
274
+ // instantly with Boom 428 from the first internal query — the message
275
+ // was simply lost unless the consumer retried. Now the send waits for
276
+ // the transport to reopen, bounded by connectTimeoutMs; a connection
277
+ // that closes for good still fails fast via waitForSocketOpen itself.
278
+ const waitMs = config.connectTimeoutMs ?? 60000;
279
+ await Promise.race([
280
+ waitForSocketOpen(),
281
+ delay(waitMs).then(() => {
282
+ throw new Boom(`Timed out waiting ${waitMs}ms for the connection to open before sending`, { statusCode: 408 }); // 408 = DisconnectReason.timedOut
283
+ })
284
+ ]);
285
+ }
272
286
  const meId = authState.creds.me.id;
273
287
  let shouldIncludeDeviceIdentity = false;
274
288
  const { user, server } = jidDecode(jid);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aunubaileys",
3
3
  "type": "module",
4
- "version": "1.0.19",
4
+ "version": "1.0.20",
5
5
  "description": "AunuBaileys \u2014 a WhatsApp Web API for bots that never sleep. Full upstream power with the beloved in-memory store restored and pairing that just works. Forged by AunuCore.",
6
6
  "keywords": [
7
7
  "whatsapp",