davexbaileys 2.5.12 → 2.5.13

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.
@@ -555,7 +555,8 @@ export const makeSocket = (config) => {
555
555
  check if it's been a suspicious amount of time since the server responded with our last seen
556
556
  it could be that the network is down
557
557
  */
558
- if (diff > keepAliveIntervalMs + 5000) {
558
+ if (diff > keepAliveIntervalMs * 3) {
559
+ // 3x interval grace period — avoids false 408 on slow cloud platforms (Heroku, Railway etc)
559
560
  end(new Boom('Connection was lost', { statusCode: DisconnectReason.connectionLost }));
560
561
  }
561
562
  else if (ws.isOpen) {
@@ -303,13 +303,15 @@ export const getCodeFromWSError = (error) => {
303
303
  statusCode = code;
304
304
  }
305
305
  }
306
- else if (
307
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
308
- error?.code?.startsWith('E') ||
309
- error?.message?.includes('timed out')) {
310
- // handle ETIMEOUT, ENOTFOUND etc
306
+ else if (error?.message?.includes('timed out') || error?.code === 'ETIMEDOUT') {
307
+ // genuine timeout — map to connectionLost (408) for retry
311
308
  statusCode = 408;
312
309
  }
310
+ else if (error?.code?.startsWith('E')) {
311
+ // network reset/unavailable (ECONNRESET, ENOTFOUND etc) — NOT a 408 timeout loop
312
+ // use 503 so bots can distinguish and apply a smarter reconnect strategy
313
+ statusCode = 503;
314
+ }
313
315
  return statusCode;
314
316
  };
315
317
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "davexbaileys",
3
- "version": "2.5.12",
3
+ "version": "2.5.13",
4
4
  "type": "module",
5
5
  "description": "A lightweight, full-featured WhatsApp Web API library for Node.js",
6
6
  "main": "lib/index.js",