@hiroosy/baileys-lite 0.3.5 → 0.3.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": "@hiroosy/baileys-lite",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "A Lightweight Baileys built with NodeJs 18+",
5
5
  "repository": {
6
6
  "type": "git",
@@ -61,7 +61,7 @@ export const makeChatsSocket = config => {
61
61
  const historySyncStatus = { initialBootstrapComplete: false, recentSyncComplete: false }
62
62
  let historySyncPausedTimeout
63
63
  const blockedCollections = new Set()
64
- const placeholderResendCache = config.placeholderResendCache || new Cache({ ttl: DEFAULT_CACHE_TTLS.MSG_RETRY * 1000 })
64
+ const placeholderResendCache = config.placeholderResendCache || new Cache({ max: 1024, ttl: DEFAULT_CACHE_TTLS.MSG_RETRY * 1000 })
65
65
 
66
66
  const getAppStateSyncKey = async keyId => {
67
67
  const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId])
@@ -1252,7 +1252,6 @@ export const makeMessagesRecvSocket = (config) => {
1252
1252
  if (ids[0] && key.participant && (await willSendMessageAgain(ids[0], key.participant))) {
1253
1253
  if (key.fromMe) {
1254
1254
  try {
1255
- await updateSendMessageAgainCount(ids[0], key.participant);
1256
1255
  logger.debug({ attrs, key }, 'recv retry request');
1257
1256
  await sendMessagesAgain(key, ids, retryNode, node);
1258
1257
  }
@@ -1587,6 +1586,9 @@ export const makeMessagesRecvSocket = (config) => {
1587
1586
  }
1588
1587
  ]);
1589
1588
  }
1589
+ else if (attrs.id && attrs.from) {
1590
+ ev.emit('messages.update', [{ key, update: { status: WAMessageStatus.SERVER_ACK } }]);
1591
+ }
1590
1592
  };
1591
1593
 
1592
1594
  const processNodeWithBuffer = async (node, identifier, exec) => {
@@ -78,9 +78,16 @@ export const makeMessagesSocket = (config) => {
78
78
 
79
79
  let mediaHost = DEF_MEDIA_HOST;
80
80
  const refreshMediaConn = async (forceGet = false) => {
81
- const media = await mediaConn;
81
+ let media;
82
+ try {
83
+ media = await mediaConn;
84
+ }
85
+ catch {
86
+ media = undefined;
87
+ mediaConn = undefined;
88
+ }
82
89
  if (!media || forceGet || new Date().getTime() - media.fetchDate.getTime() > media.ttl * 1000) {
83
- mediaConn = (async () => {
90
+ const pending = (async () => {
84
91
  const result = await query({
85
92
  tag: 'iq',
86
93
  attrs: {
@@ -107,8 +114,15 @@ export const makeMessagesSocket = (config) => {
107
114
  }
108
115
  return node;
109
116
  })();
117
+ mediaConn = pending;
118
+ pending.catch(() => {
119
+ if (mediaConn === pending) {
120
+ mediaConn = undefined;
121
+ }
122
+ });
123
+ return pending;
110
124
  }
111
- return mediaConn;
125
+ return media;
112
126
  };
113
127
 
114
128
  const sendReceipt = async (jid, participant, messageIds, type) => {
@@ -453,7 +467,6 @@ export const makeMessagesSocket = (config) => {
453
467
  }
454
468
  catch (err) {
455
469
  logger.error({ jid, err }, 'Failed to encrypt for recipient');
456
- console.error('[sPR-DEBUG] encrypt failed for', jid, err?.message, err?.stack?.split('\n')[1]);
457
470
  return null;
458
471
  }
459
472
  });
@@ -629,7 +642,6 @@ export const makeMessagesSocket = (config) => {
629
642
  if ((!senderKeyMap[deviceJid] || !!participant) &&
630
643
  !isHostedLidUser(deviceJid) && !isHostedPnUser(deviceJid) && device.device !== 99) {
631
644
  senderKeyRecipients.push(deviceJid);
632
- senderKeyMap[deviceJid] = true;
633
645
  }
634
646
  }
635
647
  if (senderKeyRecipients.length) {
@@ -638,6 +650,9 @@ export const makeMessagesSocket = (config) => {
638
650
  const r = await createParticipantNodes(senderKeyRecipients, senderKeyMsg, extraAttrs);
639
651
  shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || r.shouldIncludeDeviceIdentity;
640
652
  participants.push(...r.nodes);
653
+ for (const node of r.nodes) {
654
+ senderKeyMap[node.attrs.jid] = true;
655
+ }
641
656
  }
642
657
  binaryNodeContent.push({ tag: 'enc', attrs: { v: '2', type: 'skmsg', ...extraAttrs }, content: ciphertext });
643
658
  await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
@@ -670,9 +685,7 @@ export const makeMessagesSocket = (config) => {
670
685
  !isHostedLidUser(deviceJid) &&
671
686
  !isHostedPnUser(deviceJid) &&
672
687
  device.device !== 99) {
673
-
674
688
  senderKeyRecipients.push(deviceJid);
675
- senderKeyMap[deviceJid] = true;
676
689
  }
677
690
  }
678
691
  if (senderKeyRecipients.length) {
@@ -688,6 +701,9 @@ export const makeMessagesSocket = (config) => {
688
701
  const result = await createParticipantNodes(senderKeyRecipients, senderKeyMsg, extraAttrs);
689
702
  shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || result.shouldIncludeDeviceIdentity;
690
703
  participants.push(...result.nodes);
704
+ for (const node of result.nodes) {
705
+ senderKeyMap[node.attrs.jid] = true;
706
+ }
691
707
  }
692
708
  binaryNodeContent.push({
693
709
  tag: 'enc',
@@ -1312,8 +1328,8 @@ export const makeMessagesSocket = (config) => {
1312
1328
  const isQuizMsg = 'poll' in content && !!content.poll?.pollType;
1313
1329
  const isAiMsg = 'ai' in content && !!content.ai;
1314
1330
  const isNeedBizAttrs = 'secureMetaServiceLabel' in content && !!content.secureMetaServiceLabel;
1315
- const additionalAttributes = options.additionalAttributes || {};
1316
- const additionalNodes = options.additionalNodes || [];
1331
+ const additionalAttributes = { ...(options.additionalAttributes || {}) };
1332
+ const additionalNodes = [...(options.additionalNodes || [])];
1317
1333
 
1318
1334
  if (isDeleteMsg || isKeepMsg) {
1319
1335
 
@@ -1367,7 +1383,6 @@ export const makeMessagesSocket = (config) => {
1367
1383
  },
1368
1384
  content: undefined
1369
1385
  });
1370
- delete content.ai;
1371
1386
  }
1372
1387
  await relayMessage(jid, fullMsg.message, {
1373
1388
  messageId: fullMsg.key.id,
@@ -60,8 +60,6 @@ export const executeWMexQuery = async (variables, queryId, dataPath, query, gene
60
60
  throw new Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result })
61
61
  }
62
62
 
63
- // requestPairingCode() menaruh me = { id, name: '~' } sebagai penanda sementara; pair-success menggantinya dengan identitas asli
64
- // sekaligus mengisi creds.account. Selama account belum ada, me itu hanyalah sisa pairing yang belum selesai.
65
63
  const isUnfinishedPairing = creds => creds?.me?.name === '~' && !creds.account
66
64
 
67
65
  export const makeSocket = config => {
@@ -80,7 +78,7 @@ export const makeSocket = config => {
80
78
  logger.warn('⚠️ DANGER: DISABLING ALL SYNC BY shouldSyncHistoryMsg PREVENTS BAILEYS FROM ACCESSING INITIAL LID MAPPINGS, LEADING TO INSTABILIY AND SESSION ERRORS')
81
79
  }
82
80
 
83
- const url = new URL(typeof waWebSocketUrl === 'string' ? waWebSocketUrl : waWebSocketUrl.href) // salinan: jangan mutasi URL milik pemanggil
81
+ const url = new URL(typeof waWebSocketUrl === 'string' ? waWebSocketUrl : waWebSocketUrl.href)
84
82
  if (config.mobile || url.protocol === 'tcp:') throw new Boom('Mobile API is not supported anymore', { statusCode: DisconnectReason.loggedOut })
85
83
  const routingInfo = authState?.creds?.routingInfo
86
84
  let wsConfig = config
@@ -122,42 +120,48 @@ export const makeSocket = config => {
122
120
  return sendRawMessage(buff)
123
121
  }
124
122
 
123
+ const connectionClosedError = () => new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed })
124
+
125
+ const listenForResponse = (msgId, timeoutMs) => {
126
+ let cleanup = () => {}
127
+ let abort = () => {}
128
+ const promise = promiseTimeout(timeoutMs, (resolve, reject) => {
129
+ const onRecv = data => resolve(data)
130
+ const onClose = () => reject(connectionClosedError())
131
+ const onError = err => reject(err instanceof Error ? err : connectionClosedError())
132
+ ws.on(`${DEF_TAG_PREFIX}${msgId}`, onRecv)
133
+ ws.on('close', onClose)
134
+ ws.on('error', onError)
135
+ abort = reject
136
+ cleanup = () => {
137
+ ws.off(`${DEF_TAG_PREFIX}${msgId}`, onRecv)
138
+ ws.off('close', onClose)
139
+ ws.off('error', onError)
140
+ }
141
+ }).finally(() => cleanup())
142
+ return { promise, abort: error => abort(error) }
143
+ }
144
+
125
145
  const waitForMessage = async (msgId, timeoutMs = defaultQueryTimeoutMs) => {
126
- let onRecv
127
- let onErr
128
146
  try {
129
- return await promiseTimeout(timeoutMs, (resolve, reject) => {
130
- onRecv = data => resolve(data)
131
- onErr = err => reject(err || new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed }))
132
- ws.on(`TAG:${msgId}`, onRecv)
133
- ws.on('close', onErr)
134
- ws.on('error', onErr)
135
- return () => reject(new Boom('Query Cancelled'))
136
- })
147
+ return await listenForResponse(msgId, timeoutMs).promise
137
148
  } catch (error) {
138
- if (error instanceof Boom && error.output?.statusCode === DisconnectReason.timedOut) {
139
- logger?.warn?.({ msgId }, 'timed out waiting for message')
140
- return undefined
141
- }
149
+ if (error instanceof Boom && error.output?.statusCode === DisconnectReason.timedOut) return undefined
142
150
  throw error
143
- } finally {
144
- if (onRecv) ws.off(`TAG:${msgId}`, onRecv)
145
- if (onErr) {
146
- ws.off('close', onErr)
147
- ws.off('error', onErr)
148
- }
149
151
  }
150
152
  }
151
153
 
152
154
  const query = async (node, timeoutMs) => {
153
155
  if (!node.attrs.id) node.attrs.id = generateMessageTag()
154
- const msgId = node.attrs.id
155
- const result = await promiseTimeout(timeoutMs, async (resolve, reject) => {
156
- const result_ = waitForMessage(msgId, timeoutMs).catch(reject)
157
- sendNode(node)
158
- .then(async () => resolve(await result_))
159
- .catch(reject)
160
- })
156
+ const listener = listenForResponse(node.attrs.id, timeoutMs || defaultQueryTimeoutMs)
157
+ listener.promise.catch(() => {})
158
+ try {
159
+ await sendNode(node)
160
+ } catch (error) {
161
+ listener.abort(error)
162
+ throw error
163
+ }
164
+ const result = await listener.promise
161
165
  if (result && 'tag' in result) assertNodeErrorFree(result)
162
166
  return result
163
167
  }
@@ -289,9 +293,6 @@ export const makeSocket = config => {
289
293
  const ev = makeEventBuffer(logger)
290
294
  const { creds } = authState
291
295
 
292
- // Sisa pairing yang tidak pernah selesai bukan sesi login: requestPairingCode() mengisi creds.me sementara (name '~')
293
- // dan itu ikut tersimpan. Kalau dibiarkan, validateConnection() mengirim LOGIN untuk nomor yang belum terdaftar,
294
- // server membalas 401 (loggedOut) dan sesi macet selamanya tanpa pernah meminta pairing lagi.
295
296
  if (isUnfinishedPairing(creds)) {
296
297
  logger.info({ me: creds.me?.id }, 'discarding unfinished pairing state from a previous attempt')
297
298
  creds.me = undefined
@@ -315,18 +316,20 @@ export const makeSocket = config => {
315
316
  if (!ws.isOpen) throw new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed })
316
317
  let onOpen
317
318
  let onClose
319
+ let onError
318
320
  const result = promiseTimeout(connectTimeoutMs, (resolve, reject) => {
319
321
  onOpen = resolve
320
- onClose = mapWebSocketError(reject)
322
+ onClose = () => reject(connectionClosedError())
323
+ onError = mapWebSocketError(reject)
321
324
  ws.on('frame', onOpen)
322
325
  ws.on('close', onClose)
323
- ws.on('error', onClose)
326
+ ws.on('error', onError)
324
327
  }).finally(() => {
325
328
  ws.off('frame', onOpen)
326
329
  ws.off('close', onClose)
327
- ws.off('error', onClose)
330
+ ws.off('error', onError)
328
331
  })
329
- if (sendMsg) sendRawMessage(sendMsg).catch(onClose)
332
+ if (sendMsg) sendRawMessage(sendMsg).catch(error => onError(error))
330
333
  return result
331
334
  }
332
335
 
@@ -390,13 +393,15 @@ export const makeSocket = config => {
390
393
  throw uploadError
391
394
  }
392
395
  }
393
- uploadPreKeysPromise = Promise.race([
394
- uploadLogic(0),
395
- new Promise((_, reject) => setTimeout(() => reject(new Boom('Pre-key upload timeout', { statusCode: 408 })), UPLOAD_TIMEOUT))
396
- ])
396
+ let uploadTimer
397
+ const uploadTimeout = new Promise((_, reject) => {
398
+ uploadTimer = setTimeout(() => reject(new Boom('Pre-key upload timeout', { statusCode: 408 })), UPLOAD_TIMEOUT)
399
+ })
400
+ uploadPreKeysPromise = Promise.race([uploadLogic(0), uploadTimeout])
397
401
  try {
398
402
  await uploadPreKeysPromise
399
403
  } finally {
404
+ clearTimeout(uploadTimer)
400
405
  uploadPreKeysPromise = null
401
406
  }
402
407
  }
@@ -458,8 +463,6 @@ export const makeSocket = config => {
458
463
  }
459
464
  })
460
465
  } catch (err) {
461
- // satu-satunya error yang sampai sini: gagal decrypt frame (counter noise tidak sinkron) -> koneksi tidak bisa dipakai lagi.
462
- // ditangani agar tidak jadi unhandled rejection yang mematikan proses.
463
466
  if (closed) return
464
467
  logger.error({ err }, 'failed to process inbound frame, closing connection')
465
468
  void end(new Boom('Connection Terminated (inbound frame failed)', { statusCode: DisconnectReason.connectionLost, data: { cause: err } }))
@@ -479,7 +482,7 @@ export const makeSocket = config => {
479
482
  consecutivePingFailures = 0
480
483
 
481
484
  ws.removeAllListeners()
482
- ws.on('error', () => {}) // error telat dari socket yang sedang ditutup tidak boleh jadi uncaught exception
485
+ ws.on('error', () => {})
483
486
 
484
487
  noise.destroy?.()
485
488
  signalRepository.close?.()
@@ -509,16 +512,18 @@ export const makeSocket = config => {
509
512
  if (ws.isClosed || ws.isClosing) throw new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed })
510
513
  let onOpen
511
514
  let onClose
515
+ let onError
512
516
  await new Promise((resolve, reject) => {
513
517
  onOpen = () => resolve(undefined)
514
- onClose = mapWebSocketError(reject)
518
+ onClose = () => reject(connectionClosedError())
519
+ onError = mapWebSocketError(reject)
515
520
  ws.on('open', onOpen)
516
521
  ws.on('close', onClose)
517
- ws.on('error', onClose)
522
+ ws.on('error', onError)
518
523
  }).finally(() => {
519
524
  ws.off('open', onOpen)
520
525
  ws.off('close', onClose)
521
- ws.off('error', onClose)
526
+ ws.off('error', onError)
522
527
  })
523
528
  }
524
529
 
@@ -568,7 +573,6 @@ export const makeSocket = config => {
568
573
  })
569
574
  }
570
575
 
571
- // Timer yang telat lebih dari ini berarti event loop sempat macet, bukan jaringan yang diam.
572
576
  const KEEPALIVE_STALL_TOLERANCE_MS = 1000
573
577
  let lastKeepAliveTick = 0
574
578
  const startKeepAliveRequest = () => {
@@ -579,13 +583,9 @@ export const makeSocket = config => {
579
583
  lastKeepAliveTick = now
580
584
  if (!lastDateRecv) lastDateRecv = new Date()
581
585
  if (stalledMs > KEEPALIVE_STALL_TOLERANCE_MS) {
582
- // Event loop sempat macet (mis. penulisan DB sinkron saat login pertama: ratusan pre-key + sync awal).
583
- // Selama macet frame dari server tidak bisa dibaca, jadi lamanya macet tidak boleh dihitung sebagai "server diam";
584
- // kalau dihitung, koneksi yang sehat diputus dengan "Connection was lost" (408) begitu loop bebas lagi.
585
586
  lastDateRecv = new Date(Math.min(now, lastDateRecv.getTime() + stalledMs))
586
587
  logger.warn({ stalledMs, keepAliveIntervalMs }, 'event loop was blocked, keep-alive silence window shifted')
587
588
  }
588
- // Penilaian ditunda ke fase check supaya frame yang sudah menumpuk di socket terbaca (fase poll) lebih dulu.
589
589
  setImmediate(runKeepAliveCheck)
590
590
  }, keepAliveIntervalMs)
591
591
  }
@@ -607,12 +607,9 @@ export const makeSocket = config => {
607
607
  const requestPairingCode = async (phoneNumber, customPairingCode) => {
608
608
  const customCode = customPairingCode == null ? '' : String(customPairingCode)
609
609
  if (customCode && customCode.length !== 8) throw new Error('Custom pairing code must be exactly 8 characters')
610
- // "+62 812-3456-7890" / "0812..." dll: jid hanya boleh berisi digit nomor internasional
611
610
  const phone = String(phoneNumber ?? '').replace(/\D/g, '')
612
611
  if (phone.length < 7 || phone.length > 15) throw new Error('Invalid phone number: use the international format, digits only (e.g. 6281234567890)')
613
612
  if (authState.creds.account) throw new Boom('Session is already paired, log out before requesting a new pairing code', { statusCode: 400 })
614
- // Socket yang sudah mati (mis. user terlalu lama mengetik nomor sampai refs QR habis & koneksi ditutup) tidak boleh
615
- // menyentuh creds: creds.me sementara yang ikut tersimpan membuat start berikutnya LOGIN dan ditolak 401.
616
613
  if (closed || !ws.isOpen) throw new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed })
617
614
 
618
615
  const previous = { me: authState.creds.me, pairingCode: authState.creds.pairingCode }
@@ -639,7 +636,6 @@ export const makeSocket = config => {
639
636
  ]
640
637
  })
641
638
  } catch (error) {
642
- // permintaan tidak sampai ke server: kembalikan creds seperti sebelum dipanggil
643
639
  authState.creds.me = previous.me
644
640
  authState.creds.pairingCode = previous.pairingCode
645
641
  ev.emit('creds.update', authState.creds)
@@ -806,7 +802,7 @@ export const makeSocket = config => {
806
802
 
807
803
  ev.on('creds.update', update => {
808
804
  const name = update.me?.name
809
- if (creds.me?.name !== name) {
805
+ if (name && name !== '~' && creds.me?.name !== name) {
810
806
  logger.debug({ name }, 'updated pushName')
811
807
  sendNode({ tag: 'presence', attrs: { name } }).catch(err => logger.warn({ trace: err.stack }, 'error in sending presence update on name change'))
812
808
  }
@@ -100,7 +100,7 @@ export class PreKeyManager {
100
100
  }
101
101
 
102
102
  const txStorage = new AsyncLocalStorage()
103
- const SIGNAL_CACHE_BYTES = 6 * 1024 * 1024
103
+ const SIGNAL_CACHE_BYTES = 1024 * 1024
104
104
 
105
105
  export function makeCacheableSignalKeyStore(store, logger, _cache) {
106
106
 
@@ -89,7 +89,7 @@ const SIGNAL_STORE_TTL_MS = 5 * 60 * 1000
89
89
  const FLUSH_TIMEOUT_MS = 3000
90
90
 
91
91
  export const useSingleFileAuthState = async fileName => {
92
- const cache = new Cache({ max: 20000, ttl: SIGNAL_STORE_TTL_MS })
92
+ const cache = new Cache({ max: 4096, ttl: SIGNAL_STORE_TTL_MS })
93
93
  const mutex = makeKeyedMutex()
94
94
  let fileData = {}
95
95
  let isLoaded = false
@@ -483,8 +483,8 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
483
483
 
484
484
  export default processMessage
485
485
 
486
- const RECENT_MESSAGES_SIZE = 512
487
- const RECENT_MESSAGES_BYTES = 4 * 1024 * 1024
486
+ const RECENT_MESSAGES_SIZE = 256
487
+ const RECENT_MESSAGES_BYTES = 1024 * 1024
488
488
  const MESSAGE_KEY_SEPARATOR = '\u0000'
489
489
  const RECREATE_SESSION_TIMEOUT = 60 * 60 * 1000
490
490
  const PHONE_REQUEST_DELAY = 3000
@@ -348,8 +348,6 @@ export const getErrorCodeFromStreamError = node => {
348
348
  const [reasonNode] = getAllBinaryNodeChildren(node)
349
349
  let reason = reasonNode?.tag || 'unknown'
350
350
  let statusCode = +(node.attrs.code || CODE_MAP[reason] || DisconnectReason.badSession)
351
- // <conflict type="replaced"/> = sesi tergantikan koneksi lain (440, jangan reconnect otomatis).
352
- // conflict dengan type lain = device dicabut dari ponsel -> sesi tidak valid lagi (401).
353
351
  if (reason === 'conflict' && !node.attrs.code) {
354
352
  if (reasonNode?.attrs?.type === 'replaced') {
355
353
  statusCode = DisconnectReason.connectionReplaced
@@ -726,7 +724,7 @@ export const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publi
726
724
  let destroyed = false
727
725
  let decodeChain = Promise.resolve()
728
726
 
729
- const MAX_IN_BYTES = 10 * 1024 * 1024
727
+ const MAX_IN_BYTES = 32 * 1024 * 1024
730
728
 
731
729
  if (routingInfo) {
732
730
  introHeader = Buffer.alloc(7 + routingInfo.byteLength + NOISE_HEADER.length)
@@ -788,7 +786,7 @@ export const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publi
788
786
  let frame = inBytes.subarray(3, size + 3)
789
787
  inBytes = inBytes.length === size + 3 ? EMPTY_BYTES : inBytes.subarray(size + 3)
790
788
  if (transport) {
791
- const result = transport.decrypt(frame) // gagal decrypt = counter tidak sinkron lagi -> biarkan melempar (fatal)
789
+ const result = transport.decrypt(frame)
792
790
  try {
793
791
  frame = await decodeBinaryNode(result)
794
792
  } catch (err) {
@@ -798,7 +796,6 @@ export const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publi
798
796
  if (destroyed) return
799
797
  }
800
798
  if (logger.level === 'trace') logger.trace({ msg: frame?.attrs?.id }, 'recv frame')
801
- // listener sinkron yang melempar tidak boleh membuang sisa frame yang sudah terbaca dari buffer
802
799
  try {
803
800
  onFrame(frame)
804
801
  } catch (err) {
@@ -867,15 +864,12 @@ export const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publi
867
864
  inBytes = inBytes.length === 0 ? newData : Buffer.concat([inBytes, newData])
868
865
  }
869
866
  if (inBytes.length > MAX_IN_BYTES) {
870
- logger.error({ bufferedBytes: inBytes.length, max: MAX_IN_BYTES }, 'noise handler inBytes buffer exceeded cap, clearing')
871
867
  inBytes = EMPTY_BYTES
872
868
  pendingOnFrame = null
873
- return
869
+ throw new Boom('Noise inbound buffer limit exceeded', { statusCode: DisconnectReason.connectionLost })
874
870
  }
875
871
  if (!isWaitingForTransport) await processData(onFrame)
876
872
  }
877
- // rantai: tiap pemanggilan menunggu yang sebelumnya selesai; error tidak meracuni rantai,
878
- // tapi tetap diteruntukkan ke pemanggil lewat promise yang dikembalikan
879
873
  const result = decodeChain.then(run)
880
874
  decodeChain = result.catch(() => {})
881
875
  return result