aunubaileys 1.0.18 β†’ 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,14 @@ 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
+
71
+ ### πŸ†• What's new in 1.0.19 / Baru di 1.0.19
72
+
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.
74
+
67
75
  ### πŸ†• What's new in 1.0.18 / Baru di 1.0.18
68
76
 
69
77
  - πŸ” **Retry receipts: the peer's own key bundle is finally used** β€” when a recipient device asks for a resend, its retry receipt often embeds that device's own current key bundle. Upstream ignored it and always re-fetched a bundle from the server (extra round trip, and JIDβ†’bundle mapping is fragile for LID participants). AunuBaileys now parses the bundle (new exported `parseRetryReceiptSession`, unit-verified) and injects it as the fresh session for the resend, skipping the server fetch for that resend. Receipts without a bundle behave exactly as before.
@@ -1,5 +1,5 @@
1
1
  import { readFileSync, writeFileSync } from 'fs';
2
- import { argv, exit } from 'process';
2
+ import { exit } from 'process';
3
3
 
4
4
  const filePath = './index.js';
5
5
 
@@ -729,7 +729,13 @@ export const makeMessagesRecvSocket = (config) => {
729
729
  else {
730
730
  logger.debug({ node }, 'connection closed, ignoring retry req');
731
731
  }
732
- });
732
+ }).catch(err => onUnexpectedError(err, 'sending retry request'));
733
+ // AunuBaileys: this mutex call is deliberately fire-and-forget
734
+ // (it must not block message processing), but until now its
735
+ // rejection was UNHANDLED β€” a failed retry request (socket
736
+ // died mid-flight, pre-key fetch error) crashed the whole
737
+ // process under Node's default unhandled-rejection policy.
738
+ // It is now routed to the standard error handler instead.
733
739
  }
734
740
  else {
735
741
  if (author) {
@@ -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.18",
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",